diff options
author | bptato <nincsnevem662@gmail.com> | 2023-09-19 16:45:09 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-09-19 16:55:22 +0200 |
commit | 415ad6988dabb1535dd0bfe9532c4395df8688e2 (patch) | |
tree | 23f25642b618f598275fc59b2301a93a13095815 /src/utils | |
parent | e8da184531c774a6388576dab3dbe4182eab9473 (diff) | |
download | chawan-415ad6988dabb1535dd0bfe9532c4395df8688e2.tar.gz |
ftp: encode paths, escape displayed strings
avoid e.g. # being interpreted as a fragment
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/twtstr.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/utils/twtstr.nim b/src/utils/twtstr.nim index 7589c262..64f66f88 100644 --- a/src/utils/twtstr.nim +++ b/src/utils/twtstr.nim @@ -546,6 +546,23 @@ func percentDecode*(input: string, si = 0): string = i += 2 inc i +func htmlEscape*(s: string): string = + var res = "" + for c in s: + if c == '<': + res &= "<" + elif c == '>': + res &= ">" + elif c == '&': + res &= "&" + elif c == '"': + res &= """ + elif c == '\'': + res &= "'" + else: + res &= c + return res + #basically std join but with char func join*(ss: openarray[string], sep: char): string = if ss.len == 0: |