Page MenuHomePhabricator

MultimediaViewer and Echo crashes for titles with '%' character in name (URIError: URI error)
Closed, ResolvedPublic

Description

The following image fails to load in the multimedia viewer:
https://ca.wikipedia.org/wiki/Andy_Warhol#/media/Fitxer:Campbells_Soup_Cans_MOMA_reduced_80%.jpg

See:
https://logstash.wikimedia.org/app/kibana#/doc/logstash-*/logstash-2020.09.01/clienterror?id=AXRLKqM_MQ_08tQagjhw&_g=h@1251ff0

Note also on occasion throws the error " TypeError: defaultUri is undefined" so may relate to the mediawiki.Uri module in core.

Event Timeline

@Ritwikchakraborty.ritwik feel free to submit a patchset. I am happy to review.

Hopefully it's a case of wrapping the mw.Uri creation in a try catch block at

https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/MultimediaViewer/+/refs/heads/master/resources/mmv/provider/mmv.provider.Image.js#64

e.g.

try {
  uri = new mw.Uri( url );
} catch(e) {}

Sir can you please help me with local setup..and how should I start

@Jdlrobson Will wrapping the below lines in a try-catch block resolve the issue and do I need to log the error in the catch statement?

uri = new mw.Uri( url );
extraParam[ this.imageQueryParameter ] = null;
url = uri.extend( extraParam ).toString();

@Jdlrobson Will wrapping the below lines in a try-catch block resolve the issue and do I need to log the error in the catch statement?

uri = new mw.Uri( url );
extraParam[ this.imageQueryParameter ] = null;
url = uri.extend( extraParam ).toString();

I suspect so - see T261799#6510614

Change 633818 had a related patch set uploaded (by Diwanshu885; owner: Diwanshu885):
[mediawiki/extensions/MultimediaViewer@master] Wrap the mw.Uri creation in a try-catch block

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

@Jdlrobson I have made a pull request in Gerrit for code review. Please check if there is something I need to update more. Thanks.

Change 635054 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/Echo@master] Catch malformed URIs

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

Jdlrobson renamed this task from MultimediaViewer crashes for titles with '%' character in name (URIError: URI error) to MultimediaViewer and Echo crashes for titles with '%' character in name (URIError: URI error).Oct 19 2020, 7:26 PM
Jdlrobson added a project: Notifications.

Change 633818 merged by jenkins-bot:
[mediawiki/extensions/MultimediaViewer@master] Wrap the mw.Uri creation in a try-catch block

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

Change 635054 merged by jenkins-bot:
[mediawiki/extensions/Echo@master] Catch malformed URIs

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

Should be taken care of now. Thanks all. Will reopen if I see the error resurface after next weeks deployment.