summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo-Philipp Wich2024-05-21 06:54:02 +0000
committerJo-Philipp Wich2024-05-21 06:54:02 +0000
commit4c01d1ebf99e8ecfa69758a9b4f450ecef7b93cd (patch)
treeecee36e2908c3072d4d681ca250ce15e69fa8fe1
parent698a53354fd280aae097efe08803c0c9a10c14c2 (diff)
fw4: substitute double quotes in strings
The nftables parser has no concept of escape characters in quoted strings, nor does it support alternative quoting styles so it is currently impossible to emit double quoted strings containing double quotes. This could cause nftables to choke on generated rulesets that contain strings with embedded quotes, e.g. within firewall rule comments. Since firewall3 (iptables based) historically allowed arbitrary characters in comments and since we want to stay backwards compatible with existing uci configurations we can not restrict the allowed input values either. Work around the issue by substituting all double quotes with single quotes when quoting strings for interpolation into the ruleset. Fixes: https://github.com/openwrt/luci/issues/7091 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--root/usr/share/ucode/fw4.uc2
1 files changed, 1 insertions, 1 deletions
diff --git a/root/usr/share/ucode/fw4.uc b/root/usr/share/ucode/fw4.uc
index 551811a..a59eb41 100644
--- a/root/usr/share/ucode/fw4.uc
+++ b/root/usr/share/ucode/fw4.uc
@@ -1643,7 +1643,7 @@ return {
quote: function(s, force) {
if (force === true || !match(s, /^([0-9A-Fa-f:.\/-]+)( \. [0-9A-Fa-f:.\/-]+)*$/))
- return `"${replace(s + "", /(["\\])/g, '\\$1')}"`;
+ return `"${replace(s, '"', "'")}"`;
return s;
},