Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: nend on March 13, 2016, 12:14:07 AM

Title: [2.0.11][2.1]Previewing Bad/Missing Encoding
Post by: nend on March 13, 2016, 12:14:07 AM
Hi,

On the preview JavaScript why don't we use encodeURIComponent instead of replace(/&#/g, \'&#\').php_to8bit().php_urlencode().

I am not saying this as a feature request, because the current setup has the script encoding wrong and sometimes halting on special Unicode characters.

I know it probably isn't going to be as easy as use a default JavaScript function compared to home brewed compatibility. I say this because there has to be a reason the team took a different route here, but I am not seeing it. From the looks here it looks like encodeURIComponent is the better option as it doesn't bug out from what I seen on these characters.
Title: Re: [2.0.11][2.1]Previewing Bad/Missing Encoding
Post by: nend on May 28, 2016, 05:56:34 PM
Unless there is a reason for it being done this way when I get back home to my workstation in another 1.5 weeks, I will submit a commit to fix this in the 2.1 branch.

Any comments/concerns?
Title: Re: [2.0.11][2.1]Previewing Bad/Missing Encoding
Post by: Arantor on May 29, 2016, 08:44:08 AM
It's that way for legacy reasons, for matching PHP's behaviours in terms of ISO encoding. If UTF-8 I believe it can be safely changed.
Title: Re: [2.0.11][2.1]Previewing Bad/Missing Encoding
Post by: nend on May 29, 2016, 10:39:37 AM
I didn't consider ISO, that explains it.

So changing this should be safe in 2.1 but in 2.0 depending on the site setup may be problematic.

Thanks for the information, I been pondering about this.
Title: Re: [2.0.11][2.1]Previewing Bad/Missing Encoding
Post by: Arantor on May 29, 2016, 10:54:45 AM
Sounds like a plan to me.

That's the terrible thing about ISO, is that it mangles a lot of stuff :(