No HTML entities on some buttons?
Posted by dmaftei
No HTML entities on some buttons? November 09, 2007 02:51PM |
Registered: 17 years ago Posts: 10 |
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 02:55PM by dmaftei.
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 02:55PM by dmaftei.
Re: No HTML entities on some buttons? November 09, 2007 04:50PM |
Admin Registered: 23 years ago Posts: 4,495 |
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 04:51PM |
Registered: 17 years ago Posts: 10 |
Re: No HTML entities on some buttons? November 09, 2007 04:53PM |
Registered: 17 years ago Posts: 10 |
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 05:30PM by dmaftei.
Re: No HTML entities on some buttons? November 10, 2007 06:29AM |
Admin Registered: 20 years ago Posts: 8,532 |
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:
Below this line, add this line:
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):
After this line, add the following code, for restoring html entities:
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
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 08:48AM |
Registered: 17 years ago Posts: 10 |
Re: No HTML entities on some buttons? November 10, 2007 09:25AM |
Registered: 17 years ago Posts: 10 |
Re: No HTML entities on some buttons? November 10, 2007 02:25PM |
Admin Registered: 20 years ago Posts: 8,532 |
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
Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.