Merge pull request #37421 from akhilnarang/fix-filter-processing

fix: use `JSON.parse()` for filter processing
This commit is contained in:
Akhil Narang 2026-02-24 22:30:57 +05:30 committed by GitHub
commit 82d46d91c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View file

@ -76,6 +76,18 @@ class Workspace(Document):
if self.public and not is_workspace_manager() and not disable_saving_as_public():
frappe.throw(_("You need to be Workspace Manager to edit this document"))
if (
not self.public
and self.for_user
and self.for_user != frappe.session.user
and not is_workspace_manager()
):
frappe.throw(
_("You are not allowed to edit this workspace"),
frappe.PermissionError,
)
if self.has_value_changed("title"):
validate_route_conflict(self.doctype, self.title)
else:

View file

@ -1909,7 +1909,13 @@ Object.assign(frappe.utils, {
process_filter_expression(filter) {
let filters = [];
filters = filter ? new Function(`return ${filter}`)() : [];
if (filter) {
try {
filters = JSON.parse(filter);
} catch {
console.warn("Invalid JSON in filter expression", filter);
}
}
return this.cleanup_filters(filters);
},
cleanup_filters(filters) {