Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security::htmlentities instead of htmlspecialchars #30

Open
ounziw opened this issue May 18, 2013 · 2 comments
Open

Security::htmlentities instead of htmlspecialchars #30

ounziw opened this issue May 18, 2013 · 2 comments

Comments

@ounziw
Copy link
Contributor

ounziw commented May 18, 2013

I propose to use FuelPHP's Security::htmlentities instead of htmlspecialchars

http://fuelphp.com/docs/classes/security.html#method_htmlentities

The reason is,
Japanese language uses UTF-8 encoding,
and FuelPHP's Security::htmlentities automatically sets encoding to UTF-8
(If FuelPHP is configured to use UTF-8, Security::htmlentities uses UTF-8).

@sdrdis
Copy link
Contributor

sdrdis commented May 27, 2013

Hi!

Sorry about the delay. We are not sure we understood your issue; do you have any bug / warning / encoding error ?

The thing is that htmlentites does much more than htmlspecialchars. We didn't succeed to reproduce any issue using htmlspecialchars and japanese characters, but since it is documented that this function use ISO-8859-1 encoding for php < 5.4.0 (http://www.php.net/manual/en/function.htmlspecialchars.php), we just implemented our own \Security::htmlspecialchars function:

novius-os/core@abebdac

Is it what you were asking for ? If yes do you need us to commit it in master/chiba ?

Thanks 😄

@ounziw
Copy link
Contributor Author

ounziw commented May 28, 2013

We didn't succeed to reproduce any issue using htmlspecialchars and japanese characters,

Yes, in normal cases, nothing is bad.
When no encoding is set, and attackers insert invalid encoded characters, some of them may pass unescaped.
http://www.tokumaru.org/d/20090930.html
http://www.tokumaru.org/d/20100927.html#p01 (these posts are from Japanese blog, written by a security master)

So htmlspecialchars($s, ENT_QUOTES, 'UTF-8') or htmlentities($s, ENT_QUOTES, 'UTF-8') is recommended, since setting the encoding is no harm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants