Page 1 of 1

html in php escaped with \ interpreted incorrectly

Posted: Fri Mar 02, 2018 10:43 am
by gmgj
Do anyone reading this , the Batch Wizard is a really easy way to check some php files. This php line

echo '<p style=\'padding-left: 15px; font-weight:bold;color:red;\'>'. __FUNCTION__.'</p>'. "\n";
and
echo '<p style=\"padding-left:15px;font-weight:bold;color:red;\">' . __FUNCTION__ . '</p>' . "\n";

generate error messages like
The value for the "style" attribute appears to use one or more invalid quotation characters. To quote attribute values, use only the U+0022 quotation mark (") or U+0027 apostrophe (') characters. Do not use accents or left or right quotation mark characters like U+2018 (‘), U+2019 (’), U+201C (“), or U+201D (”).

The attribute value "\'padding-left:" for the "style" attribute is not in single or double quotation marks when it must be. In HTML5, attribute values containing literal spaces, quotes (" or '), equal signs (=), less-than signs (<), greater-than signs (>), or grave accents (`) must be quoted. Empty strings must also be quoted. In XHTML/XML, attribute values must always be quoted. Quoting values is recommended, even if it's not technically required.

Its not very good style, but it works fine. PS I check the lines in hex to make sure I did not have any funny utf-8 in it

php file attached with a zip extension.

Re: html in php escaped with \ interpreted incorrectly

Posted: Fri Mar 02, 2018 10:47 am
by gmgj
I am in the process of updating this file to php 7 standards. I whacked the version I sent you, please add a $ to blowfish_salt on line 836

Re: html in php escaped with \ interpreted incorrectly

Posted: Fri Mar 02, 2018 2:57 pm
by Albert Wiersch
Hello,

Thank you. I've looked at the file. CSS HTML Validator is parsing that section like it's HTML but it's PHP instead and CSS HTML Validator should not be trying to check it as HTML. If you delete line 557 (with "?>") then it seems to fix the problem and the section is recognized as PHP code.

There's another issue on this line that confuses CSS HTML Validator:

Code: Select all

	$out='<?xml version="1.0"?><data>'.$out.'</data>';
Please change the line to:

Code: Select all

	$out='<?xml version="1.0"?'.'><data>'.$out.'</data>';
So that CSS HTML Validator doesn't get confusing with the '?>' in the string and think that the PHP section is over.