fix: Add likely missing escapes (backport #55574) (#55580)

* fix: Add likely missing escaps (#55574)

(cherry picked from commit b72cde73ba)

# Conflicts:
#	erpnext/accounts/doctype/budget/budget.py
#	erpnext/controllers/website_list_for_contact.py

* chore: conflicts

---------

Co-authored-by: Ankush Menat <ankush@frappe.io>
This commit is contained in:
mergify[bot]
2026-06-18 11:32:54 +00:00
committed by GitHub
parent f3334eb2d3
commit ce8fce78f1
10 changed files with 44 additions and 27 deletions

View File

@@ -394,9 +394,9 @@ class StatusUpdater(Document):
for args in self.status_updater:
# condition to include current record (if submit or no if cancel)
if self.docstatus == 1:
args["cond"] = " or parent='%s'" % self.name.replace('"', '"')
args["cond"] = " or parent=%s" % frappe.db.escape(self.name)
else:
args["cond"] = " and parent!='%s'" % self.name.replace('"', '"')
args["cond"] = " and parent!=%s" % frappe.db.escape(self.name)
self._update_children(args, update_modified)
@@ -426,9 +426,10 @@ class StatusUpdater(Document):
args["second_source_condition"] = frappe.db.sql(
""" select ifnull((select sum({second_source_field})
from `tab{second_source_dt}`
where `{second_join_field}`='{detail_id}'
where `{second_join_field}`=%(detail_id)s
and (`tab{second_source_dt}`.docstatus=1)
{second_source_extra_cond}), 0) """.format(**args)
{second_source_extra_cond}), 0) """.format(**args),
{"detail_id": args["detail_id"]},
)[0][0]
if args["detail_id"]:
@@ -439,9 +440,10 @@ class StatusUpdater(Document):
frappe.db.sql(
"""
(select ifnull(sum({source_field}), 0)
from `tab{source_dt}` where `{join_field}`='{detail_id}'
from `tab{source_dt}` where `{join_field}`=%(detail_id)s
and (docstatus=1 {cond}) {extra_cond})
""".format(**args)
""".format(**args),
{"detail_id": args["detail_id"]},
)[0][0]
or 0.0
)
@@ -452,7 +454,8 @@ class StatusUpdater(Document):
frappe.db.sql(
"""update `tab{target_dt}`
set {target_field} = {source_dt_value} {update_modified}
where name='{detail_id}'""".format(**args)
where name=%(detail_id)s""".format(**args),
{"detail_id": args["detail_id"]},
)
def _update_percent_field_in_targets(self, args, update_modified=True):

View File

@@ -7,7 +7,7 @@ import json
import frappe
from frappe import _
from frappe.modules.utils import get_module_app
from frappe.utils import flt, has_common
from frappe.utils import cint, flt, has_common
from frappe.utils.user import is_website_user