Firefox PHP

No HTML entities on some buttons?

Posted by dmaftei 
No HTML entities on some buttons?
November 09, 2007 08:51PM
Posting here because I think it has to do with localization...

What I'm doing is adding diacritics to the Romanian translation. The diacritics go as HTML entities in the language file. Everything seems to go fine, except for a couple of buttons: "Post Message" (for reply both with and without quoting) and "Save Changes" (for edit message). For these two buttons, what should show as a Romanian character with a diacritic, shows as the entity name. I don't know how to show an example here, but if any of you gentlemen wants to see this in action, I can PM you the URL, username and password where it can be seen.

The page source shows
ă
instead of
ă

Am I doing something really dumb, or did I hit a bug here?! Any suggestions how to get around this?

TIA
dmaftei



Edited 1 time(s). Last edit at 11/09/2007 08:55PM by dmaftei.
Re: No HTML entities on some buttons?
November 09, 2007 10:50PM
I think we just had a similar discussion in another thread. Is there no support in UTF-8 for these characters or is there no proper character set for these characters? The best solution is to use a character set appropriate for these characters and to use the actual characters in the language file, not entities.

Brian - Cowboy Ninja Coder - Personal Blog - Twitter
Re: No HTML entities on some buttons?
November 09, 2007 10:51PM
Same thing happens for the title... Somewhere between the language file and the actual display (in these cases), the "&" in the entity gets converted to "&".

Regards,
dmaftei
Re: No HTML entities on some buttons?
November 09, 2007 10:53PM
Quote
brianlmoon
...
The best solution is to use a character set appropriate for these characters and to use the actual characters in the language file, not entities.

I get the same result with actual characters and entities: where it works, it works, where it doesn't (the two buttons and the title), it doesn't.

Regards,
dmaftei



Edited 1 time(s). Last edit at 11/09/2007 11:30PM by dmaftei.
Re: No HTML entities on some buttons?
November 10, 2007 12:29PM
It's not exactly the same discussion. The other thread was about entering html entities inside message bodies when posting. For the language file, it's possible to use html entities and we normally do not run htmlspecialchars() on it to make it XSS safe. For the posting button, I added a fix to the code. This fix will be in the next version of Phorum.

Edit posting.php. Find the line that says:
if ($var == "meta") continue;

Below this line, add this line:
if ($var == "submitbutton_text") continue;

That will fix the post button.

I don't know what to do about the title. I guess we run htmlspecialchars() on it for a reason, but currently I don't have the time to follow the full path for setting the title to see if it is really needed. If you want to experiment with it, then find this code in common.php (line breaks added for readability):
// HTML titles can't contain HTML code, so we strip HTML tags
// and HTML escape the title.
$PHORUM["DATA"]["HTML_TITLE"] = htmlspecialchars(
strip_tags($PHORUM["DATA"]["HTML_TITLE"]), 
ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);

After this line, add the following code, for restoring html entities:
$PHORUM["DATA"]["HTML_TITLE"] =
preg_replace('/&#(\w+);/', '&#$1;', $PHORUM["DATA"]["HTML_TITLE"]);


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: No HTML entities on some buttons?
November 10, 2007 02:48PM
Thanks, Maurice, I'll try your changes and let you know how it goes.

Regards,
dmaftei
Re: No HTML entities on some buttons?
November 10, 2007 03:25PM
Both worked, thanks a lot.

Regards,
dmaftei
Re: No HTML entities on some buttons?
November 10, 2007 08:25PM
Great. The button solution is in core and will be kept. For the title, it's possibly a different story, but this hack should get you going.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login