Properly encode file path in diff view

Bug: Issue 4827
Change-Id: Ia0815aca6649324fe9f3ad7c5e2168c25d1f8a7d
This commit is contained in:
Wyatt Allen 2016-11-01 16:11:07 -07:00
parent d5aa2ff544
commit 20693de09f
3 changed files with 11 additions and 1 deletions

View File

@ -16,6 +16,7 @@ limitations under the License.
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../bower_components/iron-dropdown/iron-dropdown.html">
<link rel="import" href="../../../behaviors/gr-url-encoding-behavior.html">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior.html">
<link rel="import" href="../../../behaviors/rest-client-behavior.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">

View File

@ -92,6 +92,7 @@
behaviors: [
Gerrit.KeyboardShortcutBehavior,
Gerrit.RESTClientBehavior,
Gerrit.URLEncodingBehavior,
],
observers: [
@ -389,7 +390,7 @@
_getDiffURL: function(changeNum, patchRange, path) {
return '/c/' + changeNum + '/' + this._patchRangeStr(patchRange) + '/' +
path;
this.encodeURL(path, true);
},
_computeDiffURL: function(changeNum, patchRangeRecord, path) {

View File

@ -590,5 +590,13 @@ limitations under the License.
assert.isTrue(replaceStateStub.called);
});
test('_getDiffURL encodes special characters', function() {
var changeNum = 123;
var patchRange = {basePatchNum: 123, patchNum: 456};
var path = 'c++/cpp.cpp';
assert.equal(element._getDiffURL(changeNum, patchRange, path),
'/c/123/123..456/c%252B%252B/cpp.cpp');
});
});
</script>