From aaefd066f0b65f16f73386bc4e77e954be3bf187 Mon Sep 17 00:00:00 2001 From: Sumit Bhanushali Date: Fri, 6 Dec 2024 13:03:27 +0530 Subject: [PATCH] fix: validate "format:" expression to only contain one set of {#} pattern --- frappe/core/doctype/doctype/doctype.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frappe/core/doctype/doctype/doctype.py b/frappe/core/doctype/doctype/doctype.py index 27e0ab8209..d8e994d0da 100644 --- a/frappe/core/doctype/doctype/doctype.py +++ b/frappe/core/doctype/doctype/doctype.py @@ -1090,6 +1090,12 @@ def validate_series(dt, autoname=None, name=None): df.unique = 1 break + if autoname and autoname.startswith("format:"): + from frappe.model.naming import BRACED_PARAMS_HASH_PATTERN + + if len(BRACED_PARAMS_HASH_PATTERN.findall(autoname)) > 1: + frappe.throw(_("Only one set of {#} pattern is allowed in the format string")) + if ( autoname and (not autoname.startswith("field:"))