Stop double encoding in the URL
Also stop encoding @. This will make URLs more readable.
Consistently don't encode /. This was enabled by earlier changes that
make sure that all route pattern are regular expressions. The special
:param matching of page.js did not work with `/` chars.
Release-Notes: skip
Change-Id: I15f864505811fa2c04cfb5bbb00b643464f40f3c
diff --git a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
index 944cd7a..a2de840 100644
--- a/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-plugin-list/gr-plugin-list.ts
@@ -173,7 +173,7 @@
}
private computePluginUrl(id: string) {
- return getBaseUrl() + '/' + encodeURL(id, true);
+ return getBaseUrl() + '/' + encodeURL(id);
}
}
diff --git a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
index 981cbe4..41ad3f8 100644
--- a/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
+++ b/polygerrit-ui/app/elements/admin/gr-repo-detail-list/gr-repo-detail-list.ts
@@ -438,7 +438,7 @@
// TODO: Replace with `createRepoUrl()`, but be aware that `encodeURL()`
// gets `false` as a second parameter here. The router pattern in gr-router
// does not handle the filter URLs, if the repo is not encoded!
- return `/admin/repos/${encodeURL(repo ?? '', false)},${detailType}`;
+ return `/admin/repos/${encodeURL(repo ?? '')},${detailType}`;
}
private computeWeblink(repo: ProjectInfo | BranchInfo | TagInfo) {
diff --git a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts
index 975dd3b..5f0a171 100644
--- a/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts
+++ b/polygerrit-ui/app/elements/admin/gr-rule-editor/gr-rule-editor.ts
@@ -343,7 +343,7 @@
// private but used in test
computeGroupPath(groupId?: string) {
if (!groupId) return;
- return `${getBaseUrl()}/admin/groups/${encodeURL(groupId, true)}`;
+ return `${getBaseUrl()}/admin/groups/${encodeURL(groupId)}`;
}
// private but used in test
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
index 94467b5..a841958 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router.ts
@@ -35,6 +35,7 @@
import {fireAlert, firePageError} from '../../../utils/event-util';
import {windowLocationReload} from '../../../utils/dom-util';
import {
+ encodeURL,
getBaseUrl,
PatchRangeParams,
toPath,
@@ -969,7 +970,7 @@
if (ctx.params[0].toLowerCase() === 'self') {
this.redirectToLogin(ctx.canonicalPath);
} else {
- this.redirect('/q/owner:' + encodeURIComponent(ctx.params[0]));
+ this.redirect('/q/owner:' + encodeURL(ctx.params[0]));
}
} else {
const state: DashboardViewState = {
@@ -1275,7 +1276,7 @@
}
handleChangeNumberLegacyRoute(ctx: PageContext) {
- this.redirect('/c/' + encodeURIComponent(ctx.params[0]));
+ this.redirect('/c/' + ctx.params[0]);
}
handleChangeRoute(ctx: PageContext) {
@@ -1578,9 +1579,7 @@
}
handleDocumentationSearchRedirectRoute(ctx: PageContext) {
- this.redirect(
- '/Documentation/q/filter:' + encodeURIComponent(ctx.params[0])
- );
+ this.redirect('/Documentation/q/filter:' + encodeURL(ctx.params[0]));
}
handleDocumentationRedirectRoute(ctx: PageContext) {
diff --git a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
index 6cad45c..3ca7bdc 100644
--- a/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
+++ b/polygerrit-ui/app/elements/core/gr-router/gr-router_test.ts
@@ -373,9 +373,9 @@
view: GerritView.SETTINGS,
emailToken: 'asdf',
});
- await checkUrlToState('/settings/VE/asdf%2520qwer', {
+ await checkUrlToState('/settings/VE/asdf%40qwer', {
view: GerritView.SETTINGS,
- emailToken: 'asdf+qwer',
+ emailToken: 'asdf@qwer',
});
});
@@ -1008,8 +1008,8 @@
'/Documentation/q/filter:asdf'
);
await checkRedirect(
- '/Documentation/q/as%20df',
- '/Documentation/q/filter:as%20df'
+ '/Documentation/q/as%3Fdf',
+ '/Documentation/q/filter:as%3Fdf'
);
await checkUrlToState('/Documentation/q/filter:', {
diff --git a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.ts b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.ts
index e7c0536..71f8391 100644
--- a/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-account-label/gr-account-label_test.ts
@@ -88,7 +88,7 @@
/* HTML */ `
<div class="container">
<gr-hovercard-account for="hovercardTarget"></gr-hovercard-account>
- <a class="ownerLink" href="/q/owner:user-31%2540" tabindex="-1">
+ <a class="ownerLink" href="/q/owner:user-31@" tabindex="-1">
<span class="hovercardTargetWrapper">
<gr-avatar hidden="" imagesize="32"> </gr-avatar>
<span
diff --git a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account-contents_test.ts b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account-contents_test.ts
index b217562..a1ac781 100644
--- a/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account-contents_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-hovercard-account/gr-hovercard-account-contents_test.ts
@@ -79,7 +79,7 @@
</div>
<div class="links">
<gr-icon icon="link" class="linkIcon"></gr-icon>
- <a href="/q/owner:kermit%2540gmail.com">Changes</a>
+ <a href="/q/owner:kermit@gmail.com">Changes</a>
·
<a href="/dashboard/31415926535">Dashboard</a>
</div>
@@ -114,7 +114,7 @@
</div>
<div class="links">
<gr-icon class="linkIcon" icon="link"> </gr-icon>
- <a href="/q/owner:kermit%2540gmail.com"> Changes </a>
+ <a href="/q/owner:kermit@gmail.com"> Changes </a>
·
<a href="/dashboard/31415926535"> Dashboard </a>
</div>
diff --git a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
index f5837e3..7e90c8d 100644
--- a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
+++ b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view.ts
@@ -169,7 +169,7 @@
if (!this.isConnected || !this.path) return;
if (filter) {
this.getNavigation().setUrl(
- `${this.path}/q/filter:${encodeURL(filter, false)}`
+ `${this.path}/q/filter:${encodeURL(filter)}`
);
return;
}
@@ -190,7 +190,7 @@
const newOffset = Math.max(0, offset + this.itemsPerPage * direction);
let href = getBaseUrl() + (this.path ?? '');
if (this.filter) {
- href += '/q/filter:' + encodeURL(this.filter, false);
+ href += '/q/filter:' + encodeURL(this.filter);
}
if (newOffset > 0) {
href += `,${newOffset}`;
diff --git a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view_test.ts b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view_test.ts
index ecc1c25..cce2840 100644
--- a/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view_test.ts
+++ b/polygerrit-ui/app/elements/shared/gr-list-view/gr-list-view_test.ts
@@ -77,7 +77,7 @@
element.filter = 'plugins/';
assert.equal(
element.computeNavLink(1),
- '/admin/projects/q/filter:plugins%252F,50'
+ '/admin/projects/q/filter:plugins/,50'
);
});