ElkArte Community

Elk Development => Bug Reports => Exterminated Bugs => Topic started by: Joshua Dickerson on August 07, 2015, 04:33:33 pm

Title: " becomes "
Post by: Joshua Dickerson on August 07, 2015, 04:33:33 pm
The entity " is getting unparsed. It should remain & quot; (without the space). Even happens in code tags.

Let me see about the other entities:

" => &quot
' => &apos
< => &lt
Quote => &gt
& => &amp

Yep. Quote and add the ; to test.
Title: Re: " becomes "
Post by: emanuele on August 07, 2015, 04:58:48 pm
ehh... I never really understood why entities are translated... :-\
Title: Re: " becomes "
Post by: Joshua Dickerson on August 07, 2015, 05:33:37 pm
FYI: it isn't broken on SMF
Title: Re: " becomes "
Post by: Spuds on August 07, 2015, 05:59:11 pm
Sigh
Title: Re: " becomes "
Post by: Flavio93Zena on August 07, 2015, 08:06:16 pm
Yeah, we discovered this bug in a private conversation, randomly. :/
Title: Re: " becomes "
Post by: Spuds on August 12, 2015, 10:35:12 am
This is caused by our Utill function which set the htmlspecialchars flag to not double encode by default.

So although those characters are being saved as show meaning if you enter &quot ; that's what is saved in the DB, however to actually display it that way you need to do a &amp ;quot ; junk.

So to fix,
1) could enable double encode by default, but that gets ugly in some cases.
2) Just double encode in the preview and post areas, so in post.controller do
Code: [Select]
$form_message = Util::htmlspecialchars($_REQUEST['message'], ENT_QUOTES, 'UTF-8', true);
and
Code: [Select]
			$_POST['message'] = Util::htmlspecialchars($_POST['message'], ENT_QUOTES, 'UTF-8', true);
3) Just do it for code blocks?  Is there a reason to display it as the entity outside of a code block?
Title: Re: " becomes "
Post by: Joshua Dickerson on August 12, 2015, 03:22:04 pm
Not sure the answer but I know that it shouldn't just do it in code blocks.
Title: Re: " becomes "
Post by: Flavio93Zena on August 24, 2015, 03:50:05 am
Has this been fixed in the end?  O:-)
Title: Re: " becomes "
Post by: Spuds on August 24, 2015, 11:01:15 am
Don't know if I got all the places, but this was the first pass ... https://github.com/elkarte/Elkarte/commit/9d412fc631e47e7b47a7e414b62b441ab756a79b
Title: Re: " becomes "
Post by: Joshua Dickerson on August 24, 2015, 08:44:31 pm
Tests?
Title: Re: " becomes "
Post by: Spuds on September 04, 2015, 07:20:32 am
" => &quot;
' => &apos;
< => &lt;
Quote => &gt;
& => &amp;

Code: [Select]
&quot; &amp; &lt; or " & <