Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixed: making sure we return proper HTML action text response in API (#13010)

Damian Legawiec7830468c19e8
diff --git a/api/config/brakeman.ignore b/api/config/brakeman.ignore
new file mode 100644
index 0000000000..1651ba09f4
--- /dev/null
+++ b/api/config/brakeman.ignore
@@ -0,0 +1,24 @@
+{
+ "ignored_warnings": [
+ {
+ "warning_type": "Cross-Site Scripting",
+ "warning_code": 114,
+ "fingerprint": "8275f584e7cced41c26890e574cdbf6804bddff54374058834a562294c99d6f6",
+ "check_name": "JSONEntityEscape",
+ "message": "HTML entities in JSON are not escaped by default",
+ "file": "config/environments/production.rb",
+ "line": 5,
+ "link": "https://brakemanscanner.org/docs/warning_types/cross-site_scripting/",
+ "code": "ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false",
+ "render_path": null,
+ "location": null,
+ "user_input": null,
+ "confidence": "Medium",
+ "cwe_id": [
+ 79
+ ],
+ "note": ""
+ }
+ ],
+ "brakeman_version": "7.1.0"
+}
diff --git a/api/config/initializers/json_api_html_patch.rb b/api/config/initializers/json_api_html_patch.rb
new file mode 100644
index 0000000000..152307617a
--- /dev/null
+++ b/api/config/initializers/json_api_html_patch.rb
@@ -0,0 +1,4 @@
+# we need this until we drop Rails 8.0/7.2 support
+# Rails 8.1 will have an escape: false option
+# https://github.com/rails/rails/commit/8be58ff1e5519bf7a5772896896df0557f3d19e3
+ActiveSupport::JSON::Encoding.escape_html_entities_in_json = false