Page MenuHomePhabricator

jqueryMsg should not throw on input similar to external link syntax (whitespace in input ([ $1 $2 ] causes exceptions, [$1 $2] works)
Closed, ResolvedPublic

Description

After sending feedback from
https://pt.wikipedia.org/w/index.php?oldid=36419116&veaction=edit&uselang=pt-br&debug=1

we always get this error:

feedback-thanks: Parse error at position 52 in input: Obrigado! O seu comentário foi adicionado à página "[ $2 $1 ]".


Version: 1.23.0
Severity: minor

Details

Reference
bz51563

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 2:11 AM
bzimport set Reference to bz51563.
bzimport added a subscriber: Unknown Object (MLST).

I defined a breakpoint to the line
https://git.wikimedia.org/blob/mediawiki%2Fcore.git/1de5cb96285704977b882ddef739a55cecceb95e/resources%2Fmediawiki%2Fmediawiki.jqueryMsg.js#L824
and reloaded the page
https://pt.wikipedia.org/w/index.php?oldid=36419116&veaction=edit&uselang=pt-br&debug=1
After the VE is loaded, I clicked on "BETA" and then on "Deixar um comentário" and immediatelly got the error.

The Stack Trace was like this:

mw.jqueryMsg.parser.wikiTextToAst (mediawiki.jqueryMsg.js:824)
mw.jqueryMsg.parser.getAst (mediawiki.jqueryMsg.js:260)
mw.jqueryMsg.parser.parse (mediawiki.jqueryMsg.js:244)
(anonymous function) (mediawiki.jqueryMsg.js:116)
(anonymous function) (mediawiki.jqueryMsg.js:197)
mw.Feedback.setup (mediawiki.feedback.js:125)
mw.Feedback (mediawiki.feedback.js:66)
ve.init.mw.ViewPageTarget.onToolbarFeedbackToolClick (ve.init.mw.ViewPageTarget.js:786)
proxy (load.php?debug=true&lang=pt-br&modules=jquery%2Cme…=scripts&skin=vector&version=20130627T155106Z:775)
jQuery.event.dispatch (load.php?debug=true&lang=pt-br&modules=jquery%2Cme…scripts&skin=vector&version=20130627T155106Z:3058)
elemData.handle.eventHandle (load.php?debug=true&lang=pt-br&modules=jquery%2Cme…scripts&skin=vector&version=20130627T155106Z:2676)

Also, I typed "result" in the console and got:
["CONCAT", "Obrigado! O seu comentário foi adicionado à página ""]

Notice the current text of
https://translatewiki.net/wiki/MediaWiki:Feedback-thanks/pt-br
is this:
'Obrigado! O seu comentário foi adicionado à página "[ $2 $1 ]".'

I'm still getting the "feedback-thanks: Parse error at position 52 in input: Obrigado! O seu comentário foi adicionado à página "[ $2 $1 ]"." message when I try to post a feedback.

This particular problem was caused by the additional spaces, which the JavaScript message parser (mediawiki.jqueryMsg) apparently doesn't grok.

I adjusted the message for now.

They shouldn't throw (though that does tend to be what happens with jqueryMsg). However, neither:

[ http://example.com Example ]

[ http://example.com Example]

are treated as a text external link on the server. They both just parse the URL as a bare URL (it does accept a space before the end bracket).

So this bug only shows up when a broken message is used.

Change 113307 had a related patch set uploaded by Bartosz Dziewoński:
mediawiki.jqueryMsg: Don't throw parse errors in the user's face

https://gerrit.wikimedia.org/r/113307

The above patch sorta kinda addresses this by hiding the user-visible error messages.

(In reply to Bartosz Dziewoński from comment #6)

The above patch sorta kinda addresses this by hiding the user-visible error
messages.

Only very indirectly, so I'd prefer not to have it connected to this bug. It still isn't handling it the same as the server.

Also, marking this as low. The correct (at least so far as the server is correct) behavior for that input is for:

mw.message( 'feedback-thanks', 'Example', 'http://example.com' ).parse()

to give:

[ <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> Example ]

Note those bracket are part of the server's actual output. I don't think anyone really wants that.

matmarex claimed this task.

I don't think it's worth spending any more time on this case of broken input.