Skip to content

Commit 9d94eef

Browse files
committed
fix(cr): escape user values in review HTML and simplify onchange
- Add html_escape to _format_review_value to prevent XSS in review page - Deduplicate field clearing in _onchange_operation
1 parent 6a6e6aa commit 9d94eef

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

spp_change_request_v2/details/update_id.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,12 @@ def _onchange_operation(self):
150150
# Unlock operation when changed (user came back to edit)
151151
self.is_operation_locked = False
152152

153+
# Clear fields common to all operations
154+
self.id_type_id = False
155+
self.id_value = False
156+
self.expiry_date = False
153157
if self.operation == "add":
154158
self.existing_id_record_id = False
155-
self.id_type_id = False
156-
self.id_value = False
157-
self.expiry_date = False
158-
elif self.operation in ("update", "remove"):
159-
self.id_type_id = False
160-
self.id_value = False
161-
self.expiry_date = False
162159

163160
if warning:
164161
return {"warning": warning}

spp_change_request_v2/models/change_request.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import logging
22

3+
from markupsafe import escape as html_escape
4+
35
from odoo import _, api, fields, models
46
from odoo.exceptions import UserError, ValidationError
57

@@ -1241,9 +1243,9 @@ def _format_review_value(self, value):
12411243
return '<span class="badge text-bg-success">Yes</span>'
12421244
if isinstance(value, list):
12431245
if value:
1244-
return "<br/>".join(str(v) for v in value)
1246+
return "<br/>".join(html_escape(str(v)) for v in value)
12451247
return '<span class="text-muted">—</span>'
1246-
return str(value)
1248+
return html_escape(str(value))
12471249

12481250
def _capture_preview_snapshot(self):
12491251
"""Capture and store the preview HTML and JSON before applying changes."""

0 commit comments

Comments
 (0)