radio24/TorBox

change sed delimiter when dealing with urls

Closed this issue · 1 comments

Aiming to removeREPLACEMENT_STR for example:

REPLACEMENT_STR="$(<<< "$GO_DL_PATH" sed -e 's`[][\\/.*^$]`\\&`g')"

use | as delimiter.

$ echo $GO_DL_PATH 
https://golang.org/dl/
$ cat example.txt 
GO_DL_PATH=
$ sed "s|GO_DL_PATH=.*|GO_DL_PATH=${GO_DL_PATH}|" example.txt 
GO_DL_PATH=https://golang.org/dl/

This does not work with [] which happens to be on ipv6 bridges. So this can't be changed yet until a compatible delimiter is found:

ORIGINAL_STR="$(<<< "$ORIGINAL_STR" sed -e 's`[][\\/.*^$]`\\&`g')"

I mean, yeah, replacement string substitutes every character that could break regex, but it is not necessary when dealing with links.

This is a good point, and I will add this to CONTRIBUTING.md. When changing/adapting the code, that can be taken into account. However, I won't spend my time changing this in about 90 places in the code.