Page MenuHomePhabricator

[Bug] URI decoding fails for unescaped percent
Closed, ResolvedPublic2 Estimated Story Points

Description

Steps to reproduce

Visit http://localhost:3030/en.wikipedia.org/v1/pdf/%

Expected results

Service returns a 400 error code.

Actual results

Service returns a 500 error code and the following output:

{
  "status": 500,
  "type": "internal_error",
  "title": "URIError",
  "detail": "Failed to decode param '/en.wikipedia.org/v1/pdf/%'",
  "method": "GET",
  "uri": "/en.wikipedia.org/v1/pdf/%"
}

This is useful to users of the service, including the mobile site, to ensure that all URLs are handled properly and PDFs are returned for a variety of page titles.

Event Timeline

Jdlrobson subscribed.

I'm assuming it would be good to work on this while we work on T186127 ?
The problem appears to be the same.

Jdlrobson set the point value for this task to 2.Feb 6 2018, 5:18 PM

From Jon: don't use a RESTBase-specific solution since we're switching to an MW backend.
From Piotr: the issue is here https://github.com/wikimedia/mediawiki-services-chromium-render/blob/master/routes/html2pdf-v1.js#L26.

phuedx added subscribers: pmiazga, phuedx.

^ Per @pmiazga. T181680: Allow rendering PDFs for mobile will change the erroneous line and so fixing this task is blocked on that. We might also want to fix this as part of that work.

We should use the MediaWiki title normalization library to parse incoming article titles
https://github.com/wikimedia/mediawiki-title

T181680: Allow rendering PDFs for mobile will change the erroneous line and so fixing this task is blocked on that

I believe this task is unblocked by https://gerrit.wikimedia.org/r/#/c/408573/ (merged) but this issue still seems to be occurring. I'm claiming to at least investigate, if not fix.

mediawiki-title

For sure, if we have to do title parsing in the Service.

Change 412988 had a related patch set uploaded (by Niedzielski; owner: Stephen Niedzielski):
[mediawiki/services/chromium-render@master] Fix: return HTTP status 400 for bad URLs

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

Change 412988 merged by jenkins-bot:
[mediawiki/services/chromium-render@master] Fix: return HTTP status 400 for bad URLs

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

I downloaded latest master, ran npm install && npm start and visited http://localhost:3030/en.wikipedia.org/v1/pdf/% - I see a 400.

http://localhost:3030/en.wikipedia.org/v1/pdf/France/letter/mobile gives me a PDF.