HDFS-6662. WebHDFS cannot open a file if its path contains "%". Contributed by Gerson Carlos.

This commit is contained in:
Haohui Mai 2015-02-17 13:04:38 -08:00
parent 00b80958d8
commit 043e44bc36
4 changed files with 24 additions and 1 deletions

View File

@ -970,6 +970,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7798. Checkpointing failure caused by shared KerberosAuthenticator. HDFS-7798. Checkpointing failure caused by shared KerberosAuthenticator.
(Chengbing Liu via yliu) (Chengbing Liu via yliu)
HDFS-6662. WebHDFS cannot open a file if its path contains "%".
(Gerson Carlos via wheat9)
BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS BREAKDOWN OF HDFS-7584 SUBTASKS AND RELATED JIRAS
HDFS-7720. Quota by Storage Type API, tools and ClientNameNode HDFS-7720. Quota by Storage Type API, tools and ClientNameNode

View File

@ -50,7 +50,7 @@ class ParameterParser {
private final Map<String, List<String>> params; private final Map<String, List<String>> params;
ParameterParser(QueryStringDecoder decoder, Configuration conf) { ParameterParser(QueryStringDecoder decoder, Configuration conf) {
this.path = decoder.path().substring(WEBHDFS_PREFIX_LENGTH); this.path = QueryStringDecoder.decodeComponent(decoder.path().substring(WEBHDFS_PREFIX_LENGTH));
this.params = decoder.parameters(); this.params = decoder.parameters();
this.conf = conf; this.conf = conf;
} }

View File

@ -102,6 +102,13 @@
menus.change(); menus.change();
} }
function encode_path(abs_path) {
abs_path = encodeURIComponent(abs_path);
var re = /%2F/g;
return abs_path.replace(re, '/');
}
abs_path = encode_path(abs_path);
var url = '/webhdfs/v1' + abs_path + '?op=GET_BLOCK_LOCATIONS'; var url = '/webhdfs/v1' + abs_path + '?op=GET_BLOCK_LOCATIONS';
$.get(url).done(function(data) { $.get(url).done(function(data) {
var d = get_response(data, "LocatedBlocks"); var d = get_response(data, "LocatedBlocks");

View File

@ -52,4 +52,17 @@ public class TestParameterParser {
final Token<DelegationTokenIdentifier> tok2 = testParser.delegationToken(); final Token<DelegationTokenIdentifier> tok2 = testParser.delegationToken();
Assert.assertTrue(HAUtil.isTokenForLogicalUri(tok2)); Assert.assertTrue(HAUtil.isTokenForLogicalUri(tok2));
} }
@Test
public void testDecodePath() {
final String SCAPED_PATH = "hdfs-6662/test%25251%26%3Dtest?op=OPEN";
final String EXPECTED_PATH = "/hdfs-6662/test%251&=test";
Configuration conf = DFSTestUtil.newHAConfiguration(LOGICAL_NAME);
QueryStringDecoder decoder = new QueryStringDecoder(
WebHdfsHandler.WEBHDFS_PREFIX + "/"
+ SCAPED_PATH);
ParameterParser testParser = new ParameterParser(decoder, conf);
Assert.assertEquals(EXPECTED_PATH, testParser.path());
}
} }