Skip to content

Commit 9fbccc7

Browse files
authored
fix: encode docname when routing (backport frappe#17092) (frappe#17374) (frappe#18748)
(cherry picked from commit c8777c5) Co-authored-by: phot0n <ritwikpuri5678@gmail.com> (cherry picked from commit eb4c4fb) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 459fdc2 commit 9fbccc7

File tree

3 files changed

+3
-10
lines changed

3 files changed

+3
-10
lines changed

cypress/integration/table_multiselect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ context("Table MultiSelect", () => {
5454
"existing_value"
5555
);
5656
cy.get("@existing_value").find(".btn-link-to-form").click();
57-
cy.location("pathname").should("contain", "/user/test@erpnext.com");
57+
cy.location("pathname").should("contain", "/user/test%40erpnext.com");
5858
});
5959
});

frappe/public/js/frappe/list/list_view.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -938,11 +938,9 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
938938
return this.settings.get_form_link(doc);
939939
}
940940

941-
const docname = cstr(doc.name).match(/[%'"#\s]/) ? encodeURIComponent(doc.name) : doc.name;
942-
943941
return `/app/${frappe.router.slug(
944942
frappe.router.doctype_layout || this.doctype
945-
)}/${docname}`;
943+
)}/${encodeURIComponent(cstr(doc.name))}`;
946944
}
947945

948946
get_seen_class(doc) {

frappe/public/js/frappe/router.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,7 @@ frappe.router = {
430430
frappe.route_options = a;
431431
return null;
432432
} else {
433-
a = String(a);
434-
if (a && a.match(/[%'"#\s\t]/)) {
435-
// if special chars, then encode
436-
a = encodeURIComponent(a);
437-
}
438-
return a;
433+
return encodeURIComponent(String(a));
439434
}
440435
}).join("/");
441436
let private_home = frappe.workspaces[`home-${frappe.user.name.toLowerCase()}`];

0 commit comments

Comments
 (0)