html in php escaped with \ interpreted incorrectly

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
Post Reply
gmgj
Rank 0 - Newcomer
Posts: 5
Joined: Tue Feb 09, 2016 10:59 am

html in php escaped with \ interpreted incorrectly

Post 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.
Attachments
phpbasics.zip
(58.49 KiB) Downloaded 235 times
gmgj
Rank 0 - Newcomer
Posts: 5
Joined: Tue Feb 09, 2016 10:59 am

Re: html in php escaped with \ interpreted incorrectly

Post 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
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: html in php escaped with \ interpreted incorrectly

Post 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.
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
Post Reply