Skip to content

Commit 56df23b

Browse files
committed
[fix] Avoid replacing True/False substrings in UCI string values
1 parent e1e9b41 commit 56df23b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

netjsonconfig/backends/openwrt/renderer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
from ..base.renderer import BaseRenderer
24

35

@@ -16,8 +18,7 @@ def cleanup(self, output):
1618
.replace("\noption", "\n\toption")
1719
.replace("\nlist", "\n\tlist")
1820
)
19-
import re
20-
# convert 'True' to '1' and 'False' to '0', but only on whole words bounded by quotes e.g. 'True' -> '1'
21+
# convert True to 1 and False to 0 (exact match only, not substrings)
2122
output = re.sub(r"'True'", "'1'", output)
2223
output = re.sub(r"'False'", "'0'", output)
2324
# max 2 consecutive \n delimiters

0 commit comments

Comments
 (0)