Jump to content

Unable to update CMS pages : 'content is not valid'


Recommended Posts

Hi...We are having a problem with updating CMS pages as it says the 'content is not valid'. We didn't have this problem before when using 1.5.2 but have recently updated to 1.5.6.1 and now receive this message every time we try to save changes. Would updating again solve this? 

post-565991-0-86009300-1391102489_thumb.png

Link to comment
Share on other sites

it's because your cms page contents contains forbidden markups.

go to preferences > general and accept this option:

MlfBj43.png

 

if this will not help, it mean that you use other forbidden markups and you have to change the validate function, or just remove forbidden markups from cms page content.

Link to comment
Share on other sites

thank you for your response. we've changed our preferences as you suggested but are still getting the same message, even when i copy our existing HTML (which works) and just change the URLs to the new ones... and the URLs are correct and functioning, so i'm not sure where to look for faults?  

Link to comment
Share on other sites

for example, this is our existing code :

 

<a title="Fromagerie de Beaucoudray" href="http://gourmandenormande.com/index.php?id_cms=49&controller=cms"><img title="Fromagerie de Beaucoudray" onmouseover="this.src='http://www.gourmandenormande.com/img/cms/suppliersonrollover/onrollover125fromageriedebeacoudray.jpg';" onmouseout="this.src='http://www.gourmandenormande.com/img/cms/suppliersoriginalimage/originalimage125fromageriedebeacoudray.jpg';" src="http://www.gourmandenormande.com/img/cms/suppliersoriginalimage/originalimage125fromageriedebeacoudray.jpg" alt="Fromagerie de Beaucoudray" width="150" height="150" /></a>

 

and i'm trying to replace it with this, simply to change the images (so the only change is the URLs for the images) : 

 

<a title="Fromagerie de Beaucoudray" href="http://gourmandenormande.com/index.php?id_cms=49&controller=cms"><img title="Fromagerie de Beaucoudray" onmouseover="this.src='http://gourmandenormande.com/img/cms/suppliersonrollover/onrollover125fromageriedebeaucoudray.jpg';" onmouseout="this.src='http://gourmandenormande.com/img/cms/suppliersoriginalimage/originalimage125fromageriedebeaucoudray.jpg';" src="http://gourmandenormande.com/img/cms/suppliersoriginalimage/originalimage125fromageriedebeaucoudray.jpg" alt="Fromagerie de Beaucoudray" width="150" height="150" /></a>

 

the image changes on screen but just won't save. i get the same error message whether i try to add a new page or edit an existing page.

Link to comment
Share on other sites

ok, thank you... i am very new to this, so i may be asking obvious/ridiculous questions here but we don't use tinymce -i'm entering code directly into the PrestaShop HTML page, so when you say 'extend tinymce object features and also change validate function to accept these denied js tags', is this something i can do within PrestaShop? should i re-name/re-upload the images? and is there a reason why eg. 'onmouseover' would stop working when it has worked ok until now?

Link to comment
Share on other sites

I followed theses exactly but the validate.php mod seams to break prestashop, all pages related to presta return blank.? running 1.5.6.1

 

the tinyMCE mod seam to work, though I can not expand the window anymore :(

 

here are the modified lines per instructions for the validate.php

 

public static function isCleanHtml($html, $allow_iframe = false){
        return true;}
    {
        $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
        $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
        $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
        $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
        $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
        $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
        $events .= '|onselectstart|onstart|onstop';
    }

 

and theis is the mod for 1.5.6.x

 

        /**if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
            return false;*/

 

 

any insight as to what I'm doing wrong? I'm simply want to use some simple mouse over script in the CMS page and avoid the

Property CMS->content is not valid
at line 878 in file classes/ObjectModel.php

872. 873. 				$message = $this->validateField($field, $value, $id_lang);874. 				if ($message !== true)875. 				{876. 					if ($die)877. 						throw new PrestaShopException($message);878. 					return $error_return ? $message : false;879. 				}880. 			}881. 		}882. 

 

thanks

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

you use wrong code.

 

i never said that you have to use code like:
 


public static function isCleanHtml($html, $allow_iframe = false){
        return true;}
    {
        $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
        $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
        $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
        $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
        $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
        $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
        $events .= '|onselectstart|onstart|onstop';
    }

 

it's definitely bad! this is why you've got blank page.

 

instead of this weirdy code you have to use only this:

public static function isCleanHtml($html, $allow_iframe = false){
        return true;
}

nothing more

Link to comment
Share on other sites

Thanks for posting Milosz

 

I agree I am probably using wrong code somewhere OK, but the weirdy code is what is in the  original presta validate file. the stuff you comment out if you are using 1.5.5 or earlier according to the tutorial here

http://mypresta.eu/en/art/developer/prestashop-product-page-full-rich-editor.html

 

. No word wrap makes it look wierd. I should not have pasted that. these are the lines 396-403 basically between the 2 suggested changes, the return true statement and the commented out portion for the 1.5.6+ version

 

I do have this for the change exactly

 

public static function isCleanHtml($html, $allow_iframe = false){
        return true;

}

 

 

and this code was for 1.5.6+ this just is commented out right?

 

 

/**if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
            return false;*/

 

 

this validate.php mod still causes the site to go blank to my confusion? any more insight. I know it must be a simple error

 

jh

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

it seams to be this code only that causes the problem with 1.5.6.1 going blank. Adding this kills it dead.

 

 

 

public static function isCleanHtml($html, $allow_iframe = false){
        return true;

}

 

commenting out the other lines doesn't seem to affect anything.

Link to comment
Share on other sites

Awesome, thanks! This is just so I can use JS in CMS editor etc.

 

This is modified according to the Tut, (i believe?)

 

jhattachicon.gifValidate.php

 

 

it isn't ;)

 

take a look: you've got code:

 

	/**
	 * Check for HTML field validity (no XSS please !)
	 *
	 * @param string $html HTML field to validate
	 * @return boolean Validity is ok or not
	 */
	public static function isCleanHtml($html, $allow_iframe = false){
		return true;
	}
	
	
	
	{
		$events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
		$events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
		$events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
		$events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
		$events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
		$events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
		$events .= '|onselectstart|onstart|onstop';

		/*if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
		 *	return false;*/

		if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html))
			return false;

		return true;
	}

it's definitely bad! 

 

use only this ias i suggested:

	public static function isCleanHtml($html, $allow_iframe = false){
		return true;
	}
	

this is proper file with valid modification:

http://pastebin.com/Gk0rWdkJ#

Link to comment
Share on other sites

yes, definitely bad on my part.

 

I noticed you deleted all of this below, that wasn't clear to me in the TUT. It works now thank you so much!! this was part of the original 1.5.6.1 install so that threw me off.

 

It works now, sort of, but it doesn't break the store. When hitting SAVE in the CMS BO the page goes blank but it is saved, just have to back button to get back to the CMS editor, no big problem. But I can add JS and stuff, very cool, thanks again, I would have pounded my head against the wall for a few days!

 

    $events = 'onmousedown|onmousemove|onmmouseup|onmouseover|onmouseout|onload|onunload|onfocus|onblur|onchange';
        $events .= '|onsubmit|ondblclick|onclick|onkeydown|onkeyup|onkeypress|onmouseenter|onmouseleave|onerror|onselect|onreset|onabort|ondragdrop|onresize|onactivate|onafterprint|onmoveend';
        $events .= '|onafterupdate|onbeforeactivate|onbeforecopy|onbeforecut|onbeforedeactivate|onbeforeeditfocus|onbeforepaste|onbeforeprint|onbeforeunload|onbeforeupdate|onmove';
        $events .= '|onbounce|oncellchange|oncontextmenu|oncontrolselect|oncopy|oncut|ondataavailable|ondatasetchanged|ondatasetcomplete|ondeactivate|ondrag|ondragend|ondragenter|onmousewheel';
        $events .= '|ondragleave|ondragover|ondragstart|ondrop|onerrorupdate|onfilterchange|onfinish|onfocusin|onfocusout|onhashchange|onhelp|oninput|onlosecapture|onmessage|onmouseup|onmovestart';
        $events .= '|onoffline|ononline|onpaste|onpropertychange|onreadystatechange|onresizeend|onresizestart|onrowenter|onrowexit|onrowsdelete|onrowsinserted|onscroll|onsearch|onselectionchange';
        $events .= '|onselectstart|onstart|onstop';

        if (preg_match('/<[\s]*script/ims', $html) || preg_match('/('.$events.')[\s]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
            return false;

        if (!$allow_iframe && preg_match('/<[\s]*(i?frame|form|input|embed|object)/ims', $html))
            return false;

        return true;
    }

    /**
     * Check for product reference validity
     *
     * @param string $reference Product reference to validate
     * @return boolean Validity is ok or not
     */
    public static function isReference($reference)
    {
        return preg_match('/^[^<>;={}]*$/u', $reference);

Link to comment
Share on other sites

  • 4 months later...

I have similar problem. I am unable to change content of the cms pages. I upgraded from 1.4.6.2 to 1.5.4.1 and now won't save changes. What ever change on the cms page stays as was before after clicked save.

Link to comment
Share on other sites

  • 3 weeks later...

I have similar problem with that code:

<script> 
var yotpo_app_key = "******";
</script>
<div class='yotpo testimonials'
id='yotpo-testimonials-custom-tab'
data-lang="{$yotpoLanguage|escape:'htmlall':'UTF-8'}"></div>

When I accept TinyMCE is making something like this:

<p>
<script>// <![CDATA[
 
var yotpo_app_key = "******";
// ]]></script>
</p>
<div id="yotpo-testimonials-custom-tab" class="yotpo testimonials" data-lang="{$yotpoLanguage|escape:'htmlall':'UTF-8'}"> </div>

Does anyone help me?

Link to comment
Share on other sites

so you have to paste it to .tpl file, not to cms page editor

in addition, you have to define variables somewhere in controllers

{$yotpoLanguage|escape:'htmlall':'UTF-8'}

 

 

you copied code from module? or what?

Link to comment
Share on other sites

×
×
  • Create New...