Double-encode file path for diff view
When navigating to diff view from change view, double-encode file path to work around known pagejs library issue (see Issue 4255). Bug: Issue 4474 Change-Id: I81bafcc86c4b2c450c92380eea52f315f5652b61
This commit is contained in:
@@ -378,12 +378,13 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_computeDiffURL: function(changeNum, patchRange, path) {
|
_computeDiffURL: function(changeNum, patchRange, path) {
|
||||||
|
// @see Issue 4255 regarding double-encoding.
|
||||||
return '/c/' +
|
return '/c/' +
|
||||||
encodeURIComponent(changeNum) +
|
encodeURIComponent(changeNum) +
|
||||||
'/' +
|
'/' +
|
||||||
encodeURIComponent(this._patchRangeStr(patchRange)) +
|
encodeURIComponent(this._patchRangeStr(patchRange)) +
|
||||||
'/' +
|
'/' +
|
||||||
path;
|
encodeURIComponent(encodeURIComponent(path));
|
||||||
},
|
},
|
||||||
|
|
||||||
_patchRangeStr: function(patchRange) {
|
_patchRangeStr: function(patchRange) {
|
||||||
|
|||||||
@@ -296,5 +296,19 @@ limitations under the License.
|
|||||||
assert.isFalse(element.diffs[0].hidden);
|
assert.isFalse(element.diffs[0].hidden);
|
||||||
diffStub.restore();
|
diffStub.restore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('file name should be double-escaped', function() {
|
||||||
|
element._files = [
|
||||||
|
{__path: 'my+file.txt'},
|
||||||
|
];
|
||||||
|
element.changeNum = '42';
|
||||||
|
element.patchRange = {
|
||||||
|
basePatchNum: 'PARENT',
|
||||||
|
patchNum: '2',
|
||||||
|
};
|
||||||
|
flushAsynchronousOperations();
|
||||||
|
assert.equal(
|
||||||
|
element.$$('a').getAttribute('href'), '/c/42/2/my%252Bfile.txt');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -134,12 +134,13 @@
|
|||||||
};
|
};
|
||||||
// Don't allow diffing the same patch number against itself.
|
// Don't allow diffing the same patch number against itself.
|
||||||
if (params.basePatchNum === params.patchNum) {
|
if (params.basePatchNum === params.patchNum) {
|
||||||
|
// @see Issue 4255 regarding double-encoding.
|
||||||
page.redirect('/c/' +
|
page.redirect('/c/' +
|
||||||
encodeURIComponent(params.changeNum) +
|
encodeURIComponent(params.changeNum) +
|
||||||
'/' +
|
'/' +
|
||||||
encodeURIComponent(params.patchNum) +
|
encodeURIComponent(params.patchNum) +
|
||||||
'/' +
|
'/' +
|
||||||
encodeURIComponent(params.path));
|
encodeURIComponent(encodeURIComponent(params.path)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
normalizePatchRangeParams(params);
|
normalizePatchRangeParams(params);
|
||||||
|
|||||||
Reference in New Issue
Block a user