Jump to content

Error message when trying to add HTML code to CMS page


Recommended Posts

Hi everyone,

 

I am new to Prestashop and have been working through some issues over the last week or so, however one thing which I cannot work out is an issue when trying to add HTML code to a CMS page.

 

I either create a page or go to edit one of the default pages, click on the HTML button, add the code but when I go to save or save and preview I always get the following error message no matter what type of code I try to place on the page:

 

[PrestaShopException]

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.

 

 

 

Is there something I am doing wrong or is it an issue with Prestashop itself?

It is quite important I get this solved as I am trying to add some HTML forms for different customer sign ups which is the most important thing for my site.

Any help would be much appreciated.

 

Regards

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

Hi vekia

 

I do not know what forbidden markups are but here is an example of a form I am looking to add via HTML, thanks

 

 

 

 

<script src="http://cdn.jotfor.ms/static/jotform.js?3.2.735" type="text/javascript"></script>
<script type="text/javascript">
   JotForm.init(function(){
      JotForm.highlightInputs = false;
      JotForm.alterTexts({"alphabetic":"This field can only contain letters","alphanumeric":"This field can only contain letters and numbers.","confirmClearForm":"Are you sure you want to clear the form","confirmEmail":"E-mail does not match","email":"Enter a valid e-mail address","incompleteFields":"Please complete required (*) fields.","lessThan":"Your score should be less than","numeric":"This field can only contain numeric values","pleaseWait":"Please wait...","required":"This field is required.","uploadExtensions":"You can only upload following files:","uploadFilesize":"File size cannot be bigger than:"});
   });
</script>
<link href="http://cdn.jotfor.ms/static/formCss.css?3.2.735" rel="stylesheet" type="text/css" />
<link type="text/css" media="print" rel="stylesheet" href="http://cdn.jotfor.ms/css/printForm.css?3.2.735" />
<style type="text/css">
    .form-label{
        width:150px !important;
    }
    .form-label-left{
        width:150px !important;
    }
    .form-line{
        padding-top:6px;
        padding-bottom:6px;
    }
    .form-label-right{
        width:150px !important;
    }
    .form-all{
        width:440px;
        background:#FFFFFF;
        color:#000000 !important;
        font-family:'Verdana';
        font-size:12px;
    }
    /* Injected CSS Code */
/*--red border on error--*/
.form-validation-error {
border: 1px solid #FFB0B0 !important;
}/*---form textbox styles fixed---*/
.form-textarea, .form-textbox  {
border: 1px solid #b7bbbd;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
padding: 4px;
background:transparent !important;
width: 390px !important;
max-width: 390px !important;
-webkit-appearance: none;
-webkit-box-shadow: inset 0 0 4px rgba(0,0,0,0.2), 0 1px 0 rgb(255,255,255);
-moz-box-shadow: inset 0 0 4px rgba(0,0,0,0.2), 0 1px 0 rgb(255,255,255);
box-shadow: inset 0 0 4px rgba(0,0,0,0.2), 0 1px 0 rgb(255,255,255);
border: 1px solid #AEAEAE;
color: #333;
font-family:verdana !important;
}/*--form all styles--*/
.form-all{
float:left;
padding-left: 54px;
padding-top: 0px !important;
width: 480px;
height: 578px;
}/*---remove error message---*/
.form-error-message {display: none !important;}
.form-line-error {
background:none repeat scroll 0 0;
}
/*---button error move down---*/
.form-button-error {
margin-right: 53px;
margin-top: -8px;
display: block !important;
}/*---submit button move--*/
.form-submit-button{
margin-top:0px !important;
cursor: pointer;
}#id_6{
text-align: center !important;
font-weight: bold !important;
font-size: 25px !important;
color: #3e83a5 !important;
margin-right: 39px !important;
font-family: arial !important;
padding:0px !important;
}
#text_6{
margin-right: 20px;
padding-top: 10px;
}
.form-buttons-wrapper{
margin-right: 60px;
}.form-textarea:focus, .form-textbox:focus{
outline:none !important;
}/*--fix textarea height--*/
#input_4{
height: 95px !important;
max-height: 95px !important;
}/*--fix captcha--*/.form-captcha .form-textbox{
width:130px !important;
}
    /* Injected CSS Code */
</style>
 
<form class="jotform-form" action="http://submit.jotformeu.com/submit/40615544410344/" method="post" name="form_40615544410344" id="40615544410344" accept-charset="utf-8">
  <input type="hidden" name="formID" value="40615544410344" />
  <div class="form-all">
    <ul class="form-section">
      <li class="form-line" id="id_6">
        <div id="cid_6" class="form-input-wide">
          <div id="text_6" class="form-html">
            <div style="text-align:center;">
              Contact Us
            </div>
          </div>
        </div>
      </li>
      <li class="form-line" id="id_1">
        <label class="form-label-top" id="label_1" for="input_1">
          Name<span class="form-required">*</span>
        </label>
        <div id="cid_1" class="form-input-wide">
          <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_1" name="q1_name" size="40" value="" />
        </div>
      </li>
      <li class="form-line" id="id_3">
        <label class="form-label-top" id="label_3" for="input_3">
          E-mail<span class="form-required">*</span>
        </label>
        <div id="cid_3" class="form-input-wide">
          <input type="text" class=" form-textbox validate[required, Email]" data-type="input-textbox" id="input_3" name="q3_email" size="40" value="" />
        </div>
      </li>
      <li class="form-line" id="id_5">
        <label class="form-label-top" id="label_5" for="input_5">
          Website<span class="form-required">*</span>
        </label>
        <div id="cid_5" class="form-input-wide">
          <input type="text" class=" form-textbox validate[required]" data-type="input-textbox" id="input_5" name="q5_website" size="40" value="" />
        </div>
      </li>
      <li class="form-line" id="id_4">
        <label class="form-label-top" id="label_4" for="input_4">
          Message<span class="form-required">*</span>
        </label>
        <div id="cid_4" class="form-input-wide">
          <textarea id="input_4" class="form-textarea validate[required]" name="q4_message4" cols="40" rows="6"></textarea>
        </div>
      </li>
      <li class="form-line" id="id_7">
        <div id="cid_7" class="form-input-wide">
          <div style="text-align:center" class="form-buttons-wrapper">
            <button id="input_7" type="submit" class="form-submit-button form-submit-button-book_blue2">
              Mail Now!
            </button>
          </div>
        </div>
      </li>
      <li style="display:none">
        Should be Empty:
        <input type="text" name="website" value="" />
      </li>
    </ul>
  </div>
  <input type="hidden" id="simple_spc" name="simple_spc" value="40615544410344" />
  <script type="text/javascript">
  document.getElementById("si" + "mple" + "_spc").value = "40615544410344-40615544410344";
  </script>
</form>
Link to comment
Share on other sites

you use a lot of forbidden markups like <script>, in simple words, you can use it in cms pages content. 

to avoid this problem, you can:

- remove forbidden markups from your code (but your code will not work :D )

- extend tinymce object + validate function (guide here tinymce + validation class change)

Hi vekia

 

Thank you very much for your help, I followed the guides and it appears to be working.

Link to comment
Share on other sites

you use a lot of forbidden markups like <script>, in simple words, you can use it in cms pages content. 

to avoid this problem, you can:

- remove forbidden markups from your code (but your code will not work :D )

- extend tinymce object + validate function (guide here tinymce + validation class change)

Hi vekia

 

I had to uninstall prestashop then reinstall and I have gone through the guide again at least 3 times (after uninstalling and reinstalling) and I am back to getting the error message:

 

[PrestaShopException]

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.

 

Any idea what I am doing wrong as I just wen through the same as I did before?

 

Thanks

Link to comment
Share on other sites

Hi vekia

 

I had to uninstall prestashop then reinstall and I have gone through the guide again at least 3 times (after uninstalling and reinstalling) and I am back to getting the error message:

 

[PrestaShopException]

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.

 

Any idea what I am doing wrong as I just wen through the same as I did before?

 

Thanks

 

 

can you show me your modified validate function, please?

Link to comment
Share on other sites

hola buenas a mi me pasa exactamente lo mismo tengo la ultima version y estoy intentando poner un formulario y me sale el mismo error.

alguien me podria decir como solucionarlo, gracias

leer puesto señalado como una solución

Link to comment
Share on other sites

can you show me your modified validate function, please?

Hi, validation is:

 

//if (preg_match('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
//return false;
 
Thanks
Link to comment
Share on other sites

por favor mostrar la función entera 

please show whole function

 

Hi

 

I have not changed anything but the code shown so everything else is as it was, I just followed the guides and only changed what was advised. However, please let me know if you would like me to show you the whole code from both the validate and the form tpl files so you can check it through just to make sure I am not doing something stupid.

 

Thanks again

Link to comment
Share on other sites

yo no necesito lo que tiene en la función, pero todo funciton.

Hi, I do not speak Spanish but having translated it, let me advise a couple of things. I do not know anything about code. When you say full function, what exactly do you mean? Do you need my full validation file?

 

What happens is that the TinyMCE is options are extended but I still cannot add the HTML I need.

 

Please let me know what you need from me.

 

Thanks

Link to comment
Share on other sites

	public static function isCleanHtml($html, $allow_iframe = false)
	{
		$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;
	}

this is function:)

Link to comment
Share on other sites

yo no necesito lo que tiene en la función, pero todo funciton.

i hope this is what you are wanting as you didnt reply to my last message then locked the other thread:

 

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('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
//return false;
Link to comment
Share on other sites

 

i hope this is what you are wanting as you didnt reply to my last message then locked the other thread:

 

check my #15 post :)

 

your code is wrong.

remove whole:

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('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
//return false;

then use just

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

you have to use only this function above, it can't be duplicated, only this one.

Link to comment
Share on other sites

check my #15 post :)

 

your code is wrong.

remove whole:

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('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/ims', $html) || preg_match('/.*script\:/ims', $html))
//return false;

then use just

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

you have to use only this function above, it can't be duplicated, only this one.

Hi, sorry, I didnt get an email, nor did I for your last reply.

 

OK, I removed everything in your first screenshot and just placed the 2nd screenshot into the code and all that happens is the blank screen again.

 

Obviously I am doing something wrong but I honestly cannot figure out what it is as I have followed all instructions to the letter and still nothing.

 

It is really starting to get on my nerves now. I have heard that Prestashop 1.4 already had all this included so why the difference with 1.5?

 

Thanks for your help, I hope we can get this resolved soon.

Link to comment
Share on other sites

may i ask for something?

can you please upload your validate.php file to pastebin.org ? i will check it on my own.

 

in addition, try to remove this file:

/cache/class_index.php (backup it first)

 

 

it's not true that ps 1.4 has got this feature. It has got different solution, but it still, in fact, doesnt accept some kind of scripts and code.

Link to comment
Share on other sites

Hi, URL is http://pastebin.com/HvLtKfPW

 

Sorry as I said no idea what pastebin was. Thanks

 

 

take a look this is your funciton:

 

        public static function isCleanHtml($html, $allow_iframe = false){
 
                $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('/<[ \t\n]*script/ims', $html) || preg_match('/('.$events.')[ \t\n]*=/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;
        }

change whole code to:

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

                return true;
        }
Link to comment
Share on other sites

Hi Vekia

 

The HTML forms seems to be working but I have noticed when on a page with a HTML form and even the basic PrestaShop contact form that the sidebar, top links and the navigation menu do not work properly. Is this normal or is there something I can do to solve this issue?

 

Thanks

Link to comment
Share on other sites

Hi

 

URL is: http://hollobay.com/index.php?id_cms=11&controller=cms

 

The categories plus a slideshow do not appear on the left column and also the Help & Support drop down menu at the top right does not work and the nav menu does not work either, you can look at http://hollobay.com/index.php?id_cms=2&controller=cms to see how it should work and look.

 

Thanks again

Link to comment
Share on other sites

  • 1 year later...
×
×
  • Create New...