Moodle

Check if U+00A0 (NBSP, &#160) can be part of POSTed variable

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.8
  • Fix Version/s: None
  • Component/s: Language
  • Labels:
    None
  • Environment:
    Linux / Firefox 2.0.0.1
  • Affected Branches:
    MOODLE_18_STABLE

Description

I have realized that UTF8 NBSP character copied (or typed as Alt+0160) into the <input> or <textarea> field is converted into ordinary space by browser/server and I can not access it in the $_POST variable. Please, could you try and test following script with your browser and operating system and provide a result report?

<html>
<body>
<?php

if (isset($_POST['var'])) {
$var = $_POST['var'];
echo "##$var##<br />";
for ($i=0 ; $i < strlen($var) ; $i++) { echo ord($var[$i]).' '; }
}

?>
<form method="post" action="<? echo $_SERVER['PHP_SELF'];?>" >
(1) Type ordinary space and submit (2) Type nbsp (Alt+0160) and submit (3) compare:
<input name="var" type="text" />
<input type="submit" />
</form>
</body>
</html>

Activity

Hide
Nicolas Martignoni added a comment -

Here are some results (FYI, I'm mostly working on Mac OS X).

Mac OS X 10.4.8:
Firefox 2.0.0.2: the non-breaking space is converted in a normal space (typed or copied).
Camino 1.1a2: the non-breaking space is converted in a normal space (typed or copied).
Safari 2.0.4: the non-breaking space IS NOT converted (I get 160 with your script).

Windows XP:
Firefox 2.0: the non-breaking space is converted in a normal space (typed or copied).
Explorer 6.0: like in Safari, the non-breaking space IS NOT converted (I get 160 with your script).

Seems that Gecko browsers DO translate this, which is BAD (

Hope this helps !

Show
Nicolas Martignoni added a comment - Here are some results (FYI, I'm mostly working on Mac OS X). Mac OS X 10.4.8: Firefox 2.0.0.2: the non-breaking space is converted in a normal space (typed or copied). Camino 1.1a2: the non-breaking space is converted in a normal space (typed or copied). Safari 2.0.4: the non-breaking space IS NOT converted (I get 160 with your script). Windows XP: Firefox 2.0: the non-breaking space is converted in a normal space (typed or copied). Explorer 6.0: like in Safari, the non-breaking space IS NOT converted (I get 160 with your script). Seems that Gecko browsers DO translate this, which is BAD ( Hope this helps !
Hide
Nicolas Martignoni added a comment -

After some more playing with gecko-based browser, I can reproduce this (on Firefox 2.0 on both Mac OS X and Windows XP):

1) In a good text editor, type one (or more) non-breaking space
2) Copy it
3) Paste it in ANY text field (input text or textarea) in a gecko-based browser window
4) In the browser window select the space you just pasted
5) Copy it
6) Paste it in your good editor
7) Observe that your non-breaking space was translated in a normal space

Seems like a strange "feature" of gecko engine, that has nothing to do with POST vars.

Show
Nicolas Martignoni added a comment - After some more playing with gecko-based browser, I can reproduce this (on Firefox 2.0 on both Mac OS X and Windows XP): 1) In a good text editor, type one (or more) non-breaking space 2) Copy it 3) Paste it in ANY text field (input text or textarea) in a gecko-based browser window 4) In the browser window select the space you just pasted 5) Copy it 6) Paste it in your good editor 7) Observe that your non-breaking space was translated in a normal space Seems like a strange "feature" of gecko engine, that has nothing to do with POST vars.
Hide
Nicolas Martignoni added a comment -
Show
Nicolas Martignoni added a comment - See Mozilla bug #359303 https://bugzilla.mozilla.org/show_bug.cgi?id=359303
Hide
David Mudrak added a comment -

Thank you for testing and reporting. As a result, I suggest to concern only on keeping " " as a part of translation strings (MDL-8499). We can not do anything with U+00A0 characters in copied and pasted texts. You have to find and replace these NBSPs with " " BEFORE you paste the text into the Moodle translation form.

Show
David Mudrak added a comment - Thank you for testing and reporting. As a result, I suggest to concern only on keeping " " as a part of translation strings (MDL-8499). We can not do anything with U+00A0 characters in copied and pasted texts. You have to find and replace these NBSPs with " " BEFORE you paste the text into the Moodle translation form.
Hide
David Mudrak added a comment -

To be more precise - we WILL implement transformation of NBSPs into " " during saving the file. But translators have to use a non-Gecko browser to be able to keep these pasted/typed characters in the form. When saved, the incoming U+00A0 character will be replaced by " " text.

Show
David Mudrak added a comment - To be more precise - we WILL implement transformation of NBSPs into " " during saving the file. But translators have to use a non-Gecko browser to be able to keep these pasted/typed characters in the form. When saved, the incoming U+00A0 character will be replaced by " " text.

People

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: