diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
index 477034044a..cc172ace64 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
@@ -16,6 +16,7 @@ limitations under the License.
+
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
index 7c5001d4ce..1cca11010c 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js
@@ -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) {
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
index b0a0666731..99da821523 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
@@ -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');
+ });
});