readium / readium-js-viewer

👁 ReadiumJS viewer: default web app for Readium.js library
BSD 3-Clause "New" or "Revised" License
550 stars 186 forks source link

URI lib update (domain name sanity check) breaks nested HTTP CORS proxy URLs #643

Closed danielweck closed 7 years ago

danielweck commented 7 years ago

For example: http://readium.surge.sh/?epub=https%3A%2F%2Fcrossorigin.me%2Fhttps%3A%2F%2Freadium.firebaseapp.com%2Fepub_content%2Faccessible_epub_3 or https://readium.firebaseapp.com/?epub=https%3A%2F%2Fcrossorigin.me%2Fhttps%3A%2F%2Freadium.firebaseapp.com%2Fepub_content%2Faccessible_epub_3

Console error:

Uncaught TypeError: Hostname "crossorigin.me%2Fhttps%3A%2F%2Freadium.firebaseapp.com" contains characters other than [A-Z0-9.-:_]
    at Function.r.ensureValidHostname (URI.js:1054)
    at Function.r.parseHost (URI.js:588)
    at Function.r.parseAuthority (URI.js:598)
    at Function.r.parse (URI.js:526)
    at r.b.href (URI.js:1212)
    at new r (URI.js:70)
    at Object.D [as ensureUrlIsRelativeToApp] (EpubReader.js:123)
    at ReadiumViewer.js:114
    at dispatch (jquery.js:4737)
    at m.handle (jquery.js:4549)
danielweck commented 7 years ago

Fixed via: https://github.com/readium/readium-js-viewer/commit/31376e1d93a17690c13549a23d4f62c4a74af386

Building ... https://travis-ci.org/readium/readium-js-viewer/builds/272466391

danielweck commented 7 years ago

One more change to ensure %3A%2F%2F doesn't become %3A%252F%252F during URI manipulations: https://github.com/readium/readium-js-viewer/commit/2ace70e8b63056272e7580772c83b4035fbc62a3

Test: https://readium.firebaseapp.com/?epubs=https%3A%2F%2Fcrossorigin.me%2Fhttp%3A%2F%2Fopenaccessbooks.nyupress.org%2Foabooks-reader%2Fcloud-reader%2Fepub_content%2Fepub_library.json

Building... https://travis-ci.org/readium/readium-js-viewer/builds/272478322