Last modified: 2013-11-15 11:06:08 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 T55658, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 53658 - wfEscapeWikiText is inadequate
wfEscapeWikiText is inadequate
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
Parser (Other open bugs)
1.22.0
All All
: Normal normal (vote)
: ---
Assigned To: Nobody - You can work on this!
https://en.wikipedia.org/w/index.php?...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-01 14:47 UTC by Kevin Israel (PleaseStand)
Modified: 2013-11-15 11:06 UTC (History)
5 users (show)

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


Attachments
screenshot (64.34 KB, image/png)
2013-09-01 14:47 UTC, Kevin Israel (PleaseStand)
Details

Description Kevin Israel (PleaseStand) 2013-09-01 14:47:22 UTC
Created attachment 13209 [details]
screenshot

wfEscapeWikiText does not escape enough characters, allowing undesirable formatting through in certain cases.

To reproduce, open the following URL. This is a search for
"__TOC__ OR<CR>;a<CR>ISBN<TAB>978-3-16-148410-0<CR> a".

https://en.wikipedia.org/w/index.php?title=Special%3ASearch&profile=all&search=__TOC__%20OR%0D;a%0D:ISBN%09978-3-16-148410-0%0D%20a&fulltext=Search

Expected Result:

The text "Results 1–6 of 6 for " (from message 'showingresultsheader') is followed by "__TOC__ OR ;a ISBN 978-3-16-148410-0 a", with no special formatting or linking beyond the bolding applied by the message text.

Actual Result:

__TOC__ disappears. The first "a" appears on the next line. The ISBN is indented (as a definition in a definition list) and linked to Special:BookSources. The second "a" appears as monospaced text inside a pre element.
Comment 1 Kevin Israel (PleaseStand) 2013-09-01 15:02:23 UTC
(In reply to comment #0)
> To reproduce, open the following URL. This is a search for
> "__TOC__ OR<CR>;a<CR>ISBN<TAB>978-3-16-148410-0<CR> a".

Actually for "__TOC__ OR<CR>;a<CR>:ISBN<TAB>978-3-16-148410-0<CR> a"
Comment 2 Liangent 2013-09-02 12:02:52 UTC
To be clear, things that need to be handled here are:

1. Double underscore magic words
2. Magic links using a non-space whitespace
3. Newlines using CR instead of LF
Comment 3 Kevin Israel (PleaseStand) 2013-09-03 00:12:55 UTC
Found some others as well:

https://en.wikipedia.org/wiki/Special:Search/PMID_1
https://en.wikipedia.org/wiki/Special:Search/urn:foo

Grepping the code reveals that Sanitizer::safeEncodeAttribute does
handle the former, though not some of the other things wfEscapeWikiText
is supposed to.
Comment 4 Gerrit Notification Bot 2013-09-03 20:35:11 UTC
Change 82460 had a related patch set uploaded by Anomie:
Improve wfEscapeWikiText

https://gerrit.wikimedia.org/r/82460
Comment 5 Gerrit Notification Bot 2013-09-03 20:35:38 UTC
Change 82462 had a related patch set uploaded by Anomie:
Improve mw.text.nowiki

https://gerrit.wikimedia.org/r/82462
Comment 6 Gerrit Notification Bot 2013-09-03 23:43:55 UTC
Change 82462 merged by jenkins-bot:
Improve mw.text.nowiki

https://gerrit.wikimedia.org/r/82462
Comment 7 Gerrit Notification Bot 2013-09-03 23:46:41 UTC
Change 82460 merged by jenkins-bot:
Improve wfEscapeWikiText

https://gerrit.wikimedia.org/r/82460
Comment 8 Brad Jorsch 2013-09-04 00:06:56 UTC
Changes merged. They should be deployed to WMF wikis with 1.22wmf16, see https://www.mediawiki.org/wiki/MediaWiki_1.22/Roadmap for the schedule.
Comment 9 Kevin Israel (PleaseStand) 2013-09-04 01:09:28 UTC
What about two or more consecutive newlines? Should all newlines be escaped (not just those preceding #, *, etc.)?

For example:

> $m = new RawMessage( '$1' ); var_dump( $m->params( wfEscapeWikiText( "foo\n\n\nbar" ) )->parse() );

As of a86240a37aa729494bd4d7c7935afff4e5b62b22 I get:

string(21) "foo\n</p><p><br />\nbar"

I would expect this to be:

string(21) "foo&#10;&#10;&#10;bar"
Comment 10 Gerrit Notification Bot 2013-09-20 17:20:16 UTC
Change 85233 had a related patch set uploaded by Anomie:
Improve wfEscapeWikiText, part 2

https://gerrit.wikimedia.org/r/85233
Comment 11 Gerrit Notification Bot 2013-09-20 17:20:28 UTC
Change 85234 had a related patch set uploaded by Anomie:
Improve mw.text.nowiki, part 2

https://gerrit.wikimedia.org/r/85234
Comment 12 Gerrit Notification Bot 2013-09-24 15:55:39 UTC
Change 85233 merged by jenkins-bot:
Improve wfEscapeWikiText, part 2

https://gerrit.wikimedia.org/r/85233
Comment 13 Gerrit Notification Bot 2013-09-24 22:11:41 UTC
Change 85234 merged by jenkins-bot:
Improve mw.text.nowiki, part 2

https://gerrit.wikimedia.org/r/85234
Comment 14 Brad Jorsch 2013-09-25 14:24:31 UTC
Changes merged. They should be deployed to WMF wikis with 1.22wmf19, see https://www.mediawiki.org/wiki/MediaWiki_1.22/Roadmap for the schedule.
Comment 15 Gerrit Notification Bot 2013-11-14 15:20:39 UTC
Change 95420 had a related patch set uploaded by MarkAHershberger:
Improve mw.text.nowiki

https://gerrit.wikimedia.org/r/95420
Comment 16 Gerrit Notification Bot 2013-11-14 15:20:45 UTC
Change 95421 had a related patch set uploaded by MarkAHershberger:
Improve mw.text.nowiki, part 2

https://gerrit.wikimedia.org/r/95421
Comment 17 Gerrit Notification Bot 2013-11-14 16:46:49 UTC
Change 95421 abandoned by MarkAHershberger:
Improve mw.text.nowiki, part 2

https://gerrit.wikimedia.org/r/95421
Comment 18 Gerrit Notification Bot 2013-11-14 16:46:53 UTC
Change 95420 abandoned by MarkAHershberger:
Improve mw.text.nowiki

https://gerrit.wikimedia.org/r/95420
Comment 19 Andre Klapper 2013-11-15 11:06:08 UTC
No open patches to review here (backport patches got abandoned), hence restting status to RESOLVED FIXED. Backport_to_Stable flag might be set to "-" by hexmode.

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


Navigation
Links