Last modified: 2010-05-15 15:33:20 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T3877, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 1877 - JavaScript error in page editing in some localizations
JavaScript error in page editing in some localizations
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Page editing (Other open bugs)
1.4.x
All All
: Normal normal with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
http://ro.wikinews.org/w/index.php?ti...
:
: 2445 2465 2997 3088 3389 (view as bug list)
Depends on:
Blocks: javascript
  Show dependency treegraph
 
Reported: 2005-04-12 19:41 UTC by Brion Vibber
Modified: 2010-05-15 15:33 UTC (History)
5 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
patch for HEAD (708 bytes, patch)
2005-04-18 17:27 UTC, Michael Keppler
Details
patch for REL14 (744 bytes, patch)
2005-04-18 18:02 UTC, Michael Keppler
Details

Description Brion Vibber 2005-04-12 19:41:21 UTC
On the Romanian localization, going to an edit page triggers a JavaScript error "unterminated 
string literal" and the edit toolbar is not shown.

The edit toolbar code generation doesn't correctly escape JavaScript string literals. 
LanguageRo.php contains newlines in its infobox_alert text, which are  rendered as raw 
newlines in the generated code. JS doesn't allow multi-line string literals, so this fails.

Escaping should be fixed to introduce "\n" in the literal.
Comment 1 Michael Keppler 2005-04-12 20:52:40 UTC
In the HTML standard there is no such thing as a line break in alt-attributes of
image tags. By definition attribute values contain only space, but no line
breaks. Therefore any linebreak in the string shall be threatened like a space
by the parser. There is no way to force a line break, i.e. the character
sequence "a\nbreak" will be rendered as such and no good browser will replace
the "\n" by a newline.
As a consequence the function should replace all newlines by spaces before
outputting the JavaScript and the Romanians should remove their newlines from
those messages.
Comment 2 Brion Vibber 2005-04-12 20:56:29 UTC
As a general rule the system shouldn't break based on user input. Newlines may
behave as spaces, *that's fine*. They won't hurt anything if the string literal
is formatted correctly, and the string literal *should* be formatted correctly.
Comment 3 Michael Keppler 2005-04-18 17:27:57 UTC
Created attachment 426 [details]
patch for HEAD

Attached patch for HEAD replaces linebreaks in the inserted sample and in the
image tip (ALT text) by spaces.
Comment 4 Michael Keppler 2005-04-18 18:02:57 UTC
Created attachment 427 [details]
patch for REL14

attached patch for REL14 adds the same code like the HEAD patch
Comment 5 Brion Vibber 2005-04-30 08:04:54 UTC
The attached patches are wrong: they don't address the message that has the problem, 
and removing the line breaks is not necessary. (The message with the breaks is used to 
format a message alert box, not image alt text.)

Correct fix is addition and use of wfEscapeJsString() function, now checked in on 
HEAD.
Comment 6 Michael Keppler 2005-04-30 09:12:40 UTC
The fix for this exact problem case by Brion is correct. But to avoid the same
JavaScript error with the image tip for the future, we should use
wfEscapeJsString() on the image tip too.
Comment 7 Brion Vibber 2005-04-30 09:14:29 UTC
Somehow missed that one among the four other cases in that file and at least two 
elsewhere. Fixed now.
Comment 8 Brion Vibber 2005-06-18 20:17:16 UTC
*** Bug 2445 has been marked as a duplicate of this bug. ***
Comment 9 Brion Vibber 2005-06-20 17:50:49 UTC
*** Bug 2465 has been marked as a duplicate of this bug. ***
Comment 10 Brion Vibber 2005-07-29 22:03:20 UTC
*** Bug 2997 has been marked as a duplicate of this bug. ***
Comment 11 Brion Vibber 2005-08-11 06:18:58 UTC
*** Bug 3088 has been marked as a duplicate of this bug. ***
Comment 12 Brion Vibber 2005-09-07 23:20:50 UTC
*** Bug 3389 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links