Jump to content

Invalid characters: <>; = # {}


Recommended Posts

 

Quote

in classes/validate.php.

@musicmaster Thanks for the info about validate.php,

I did the following but it still does not work ( see screenshots ) , in my case on PS 1.7 latest version, I am trying to add a <br /> tag ( html line break ) in the category name. In my test I tried to put a hashtag #

726799856_psbug.png.2be824edb172a56a038cbae3515c5a87.png

 

When I put "Category # Test " for example,  I have tried to overwrite the file "Validate.php" , as explained on another topic by redefining the function "isCatalogName"  :

<?php
class Validate extends ValidateCore
{

    public static function isCatalogName($name)
    {
        // simple test
        return !preg_match('/[]/i', $name);
        
    }
}

 

now I should be able to put a hashtag like # but still get the error like on screenshot above. I am using latest version 1.7

I have tried different ways :

- overwritting only the file "Validate.php"
- overwritting Validate.php, but also Category.php and CMSCategory.php where the function "isCatalogName($name)" is called and removing the validation in these files.

- removing the overitten files and editing directly the Core Files in the class directory , then cleared cache, etc.
- I cleared cache in backend and also var/cache files to be sure each time, logged out / logged in administration every time. Refreshed browser cache / Changed browser too !

ps02.jpg.da6e739be1cc56f59f3c9dde944b58f1.jpg

ps01.thumb.jpg.e7a98d8916b309293b6adbeb4ce0aa1e.jpg

It does not work.

 

Edited by mlclm (see edit history)
Link to comment
Share on other sites

./classes/Category.php

find

'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128)

change to

'name' => array('type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 65000)

 

Validate.php does not need to be modified

Edited by Guest (see edit history)
Link to comment
Share on other sites

But it will never work.

It will still show the error because it always tries to create a URL from the name.
The most sensible thing is to add your own HTML field and paste the code into it.
A minimum knowledge of Prestashop 5/10 is required for editing.

Edited by Guest (see edit history)
Link to comment
Share on other sites

vor 16 Stunden schrieb Guest:

But it will never work.

It will still show the error because it always tries to create a URL from the name.
The most sensible thing is to add your own HTML field and paste the code into it.
A minimum knowledge of Prestashop 5/10 is required for editing.

I also think that not all characters should be allowed, only for pictures < = " " > otherwise there is a great risk of sql injection.

do you have an idea for a snippet of code? or instructions?

This is possible in PHPBB FORUM, it can be inserted in every category picture icon

Thank you

SF.....

Edited by SliderFlash (see edit history)
Link to comment
Share on other sites

Am I correct that you're trying to put a picture or category icon in the Menu or category list?

Write the reason for the adjustment to make it understand.

Link to comment
Share on other sites

Go to ./themes/your-theme/modules/ps_mainmenu/ps_mainmenu.tpl

Find:

{foreach from=$nodes item=node}

add after:

{if $node.image_urls|count}
            {foreach from=$node.image_urls item=image_url}
                <img src="{$image_url}" style="height:32px;margin-right: -10px;">
            {/foreach}
        {/if}

full tpl:

{assign var=_counter value=0}
{function name="menu" nodes=[] depth=0 parent=null}
    {if $nodes|count}
      <ul class="top-menu" {if $depth == 0}id="top-menu"{/if} data-depth="{$depth}">
        {foreach from=$nodes item=node}
        {if $node.image_urls|count}
            {foreach from=$node.image_urls item=image_url}
                <img src="{$image_url}" style="height:32px;margin-right: -10px;">
            {/foreach}
        {/if}
            <li class="{$node.type}{if $node.current} current {/if}" id="{$node.page_identifier}">
            {assign var=_counter value=$_counter+1}
              <a
                class="{if $depth >= 0}dropdown-item{/if}{if $depth === 1} dropdown-submenu{/if}"
                href="{$node.url}" data-depth="{$depth}"
                {if $node.open_in_new_window} target="_blank" {/if}
              >
                {if $node.children|count}
                  {* Cannot use page identifier as we can have the same page several times *}
                  {assign var=_expand_id value=10|mt_rand:100000}
                  <span class="float-xs-right hidden-md-up">
                    <span data-target="#top_sub_menu_{$_expand_id}" data-toggle="collapse" class="navbar-toggler collapse-icons">
                      <i class="material-icons add">&#xE313;</i>
                      <i class="material-icons remove">&#xE316;</i>
                    </span>
                  </span>
                {/if}
                {$node.label}
              </a>
              {if $node.children|count}
              <div {if $depth === 0} class="popover sub-menu js-sub-menu collapse"{else} class="collapse"{/if} id="top_sub_menu_{$_expand_id}">
                {menu nodes=$node.children depth=$node.depth parent=$node}
              </div>
              {/if}
            </li>
        {/foreach}
      </ul>
    {/if}
{/function}

<div class="menu js-top-menu position-static hidden-sm-down" id="_desktop_top_menu">
    {menu nodes=$menu.children}
    <div class="clearfix"></div>
</div>

 

Link to comment
Share on other sites

It is always better to write in detail what you need to do, make a screen, paint an arrow where you want to edit the code, etc., then the answer is simple and fast.

Link to comment
Share on other sites

You can also put a large category icon in the drop-down menu.
Just put the code before:

{menu nodes=$node.children depth=$node.depth parent=$node}

sample:

{if $node.image_urls|count}
  {foreach from=$node.image_urls item=image_url}
    <img src="{$image_url}" style="height:85px;">
  {/foreach}
{/if}
{menu nodes=$node.children depth=$node.depth parent=$node}

 

result:

obrazek.png.118c240752e11882a26defb82a9d9945.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...