Bug 1548776 - URL-decode all file names in GeckoJarReader. r=snorp

Assuming the URL string the JAR reader receives has been completely URL-encoded,
we need to decode not just the first nested jarUrl, as already happens through
getZipFile(), but all subsequent path components, too.

At least for jar:-URLs received from Gecko, the above assumption certainly seems
to be true.

Differential Revision: https://phabricator.services.mozilla.com/D44033

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jan Henning 2019-08-30 06:37:49 +00:00
parent 161a6ec7b4
commit e417da9ac9

View File

@ -23,8 +23,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.Stack;
/* Reads out of a multiple level deep jar file such as
@ -194,6 +196,11 @@ public final class GeckoJarReader {
// loop through children jar files until we reach the innermost one
while (!jarUrls.empty()) {
String fileName = jarUrls.pop();
try {
fileName = URLDecoder.decode(fileName, "UTF-8");
} catch (UnsupportedEncodingException e) {
// UTF-8 is always supported
}
if (inputStream != null) {
// intermediate NativeZips and InputStreams will be garbage collected.