Welcome Guest, Not a member yet? Register   Sign In
anchor() helper UTF8 bug
#1

[eluser]Référencement Google[/eluser]
There is an encoding bug in the latest SVN release using the anchor helper with French characters like é à ü è

The bug appear on the tooltip while hovering a link, this is in the title attribute of the link. I think this is due to the line #122 of the url_helper.php file:
Code:
$attributes = ' title="'.htmlentities($title).'"';

As in the PHP manual, it should use the third parameter of the function to work with UTF-8, see here: http://php.net/htmlentities

I propose this code to replace at line #120:
Code:
if ($attributes == '')
{
    $CI =& get_instance();
    $attributes = ' title="'.htmlentities($title, ENT_QUOTES, $CI->config->item('charset')).'"';
}
else
{
    $attributes = _parse_attributes($attributes);
}
#2

[eluser]Derek Jones[/eluser]
I agree that's a potential problem. However we must consider that someone will be running a charset in their config that htmlentities() and htmlspecialchars() do not support, and your solution would produce PHP errors in that instance. I have my own ideas for how it should be addressed, but I'd like to hear from you and the rest of the community as well.
#3

[eluser]Référencement Google[/eluser]
I don't know then what we can do. I personally think the htmlentities function accept the most common web used charsets.

What about having a fallback solution, like put in an array the accepted charsets and check if the config charset is in this array? If not is that array then having a fallback solution (that makes a real big think for just an HTML attribute...)

My thought is that we should let people specify manually the title attributes, there is not a big need on it, the anchor helper how it was before you add the title attribute to it was just working fine, why complicate things that just works? If somebody wants the title attribute, then he will have to put it in the extra parameter, what's the community thought about this?
#4

[eluser]Derek Jones[/eluser]
It's missing windows-1253, us-ascii, all of the iso-2022 family and many others still in common use. And some like windows-1251 aren't supported until PHP 4.3.2. The good news is that utf-8 has finally passed (by Google's data) the mark of being the most common charset used.

However, even if we determine to leave these others behind, we can't let PHP errors occur. An array validation is what I was thinking too (and is what we do in ExpressionEngine). I hadn't considered removing the automatic title= attribute as it's so common and desired that it can be a real time and thought saver for the developer not to have to create and set that attribute manually for every URL.
#5

[eluser]Référencement Google[/eluser]
I think you should go with the accepted charsets in an array, I don't see another solution after many thoughts.
#6

[eluser]Derek Jones[/eluser]
After polling a few people who do much more front-end web development that we do, we've actually decided that the simpler solution is indeed the better. die('default title');
#7

[eluser]tomcode[/eluser]
Good news. The title attribute does bother me for certain types of anchor uses (menus ...), so I welcome the sudden death. And I can delete my homegrown charset solution, too.
#8

[eluser]Référencement Google[/eluser]
That's a good decision then because I didn't liked for example to see tool tips while hovering my Main navigation. Thanks Derek.




Theme © iAndrew 2016 - Forum software by © MyBB