Skip to content

Commit 01074ab

Browse files
authored
Merge pull request #46 from Zwelf/pr-add-new-setting-better-escaping
DDNet wiki add new settings and better escaping
2 parents 147c2fd + 4231d2e commit 01074ab

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

client_wiki/commands.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import sys
44
import re
5-
import html
65

76
offset = int(sys.argv[2])
87

@@ -11,6 +10,9 @@
1110
print(f"! <translate><!--T:{offset+2}--> Arguments</translate>")
1211
print(f"! <translate><!--T:{offset+3}--> Description</translate>")
1312

13+
def escape(inp):
14+
return inp.replace("|", "<nowiki>|</nowiki>")
15+
1416
commands = {
1517
"save_dry": 0,
1618
"mute": 1,
@@ -269,15 +271,15 @@
269271
idx = offset + 100 + commands["ban2"]*5
270272
had_ban = True
271273
print("|-")
272-
print("|", html.escape(y[1]))
274+
print("|", escape(y[1]))
273275
if y[3].strip() == "":
274276
print("|")
275277
else:
276-
print(f"| <translate><!--T:{idx}--> {html.escape(y[3])}</translate>")
278+
print(f"| <translate><!--T:{idx}--> {escape(y[3])}</translate>")
277279
if y[-2].strip() == "":
278280
print("|")
279281
else:
280-
print(f"| <translate><!--T:{idx+1}--> {html.escape(y[-2])}</translate>")
282+
print(f"| <translate><!--T:{idx+1}--> {escape(y[-2])}</translate>")
281283

282284
print('|}')
283285

client_wiki/settings.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import sys
44
import re
5-
import html
5+
6+
def escape(inp):
7+
return inp
68

79
offset = int(sys.argv[2])
810

@@ -530,13 +532,15 @@
530532
"ui_toolbox_page": 513,
531533
"ui_unread_news": 514,
532534
# add new settings below here with increasing numbers
535+
"sv_emoticon_ms_delay": 515,
536+
"sv_global_emoticon_ms_delay": 516,
533537
}
534538

535539
names = {}
536540
results = []
537541

538542
def getValue(x):
539-
return html.escape(x.lstrip()).replace("SERVERINFO_LEVEL_MIN", "0").replace("SERVERINFO_LEVEL_MAX", "2").replace("MAX_CLIENTS", "64")
543+
return escape(x.lstrip()).replace("SERVERINFO_LEVEL_MIN", "0").replace("SERVERINFO_LEVEL_MAX", "2").replace("MAX_CLIENTS", "64")
540544

541545
for line in sys.stdin:
542546
if sys.argv[1] not in line:
@@ -548,11 +552,11 @@ def getValue(x):
548552
idx = offset + 100 + settings[name] * 5
549553

550554
if "MACRO_CONFIG_STR" in line:
551-
result = (html.escape(name), idx, html.escape(y[-2]), getValue(x[3].lstrip()), "", "")
555+
result = (escape(name), idx, escape(y[-2]), getValue(x[3].lstrip()), "", "")
552556
elif "MACRO_CONFIG_INT" in line:
553-
result = (html.escape(name), idx, html.escape(y[-2]), getValue(x[2].lstrip()), getValue(x[3]), getValue(x[4]))
557+
result = (escape(name), idx, escape(y[-2]), getValue(x[2].lstrip()), getValue(x[3]), getValue(x[4]))
554558
elif "MACRO_CONFIG_COL" in line:
555-
result = (html.escape(name), idx, html.escape(y[-2]), getValue(x[2].lstrip()), "", "")
559+
result = (escape(name), idx, escape(y[-2]), getValue(x[2].lstrip()), "", "")
556560

557561
line = "|-\n"
558562
if y[-2].strip() == "":

client_wiki/tunings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import sys
44
import re
5-
import html
5+
6+
def escape(inp):
7+
return inp
68

79
tunings = {
810
"ground_control_speed": 0,
@@ -71,7 +73,7 @@ def foo(x):
7173
x = re.findall(r'(?:[^,"]|"(?:\\.|[^"])*")+', line)
7274

7375
idx = offset + 100 + tunings[x[1].strip()] * 5
74-
result = (html.escape(x[1].strip()), idx, html.escape(x[3].strip(" )\n").split('"')[-2]), html.escape(str(foo(x[2]))))
76+
result = (escape(x[1].strip()), idx, escape(x[3].strip(" )\n").split('"')[-2]), escape(str(foo(x[2]))))
7577

7678
print("|-")
7779
print("| %s\n| <translate><!--T:%s--> %s</translate>\n| %s" % result)

0 commit comments

Comments
 (0)