Code: Select all
tmpsharedir = data['sharedir'].replace(" ", "\\ ")
if tmpsharedir[-1:] == "$":
tmpdir = tmpsharedir.replace("$", "\\$")
tmpsharedir = tmpdir
I'm asking because it appears that CIFS share names that end in "$" are hidden shares, and I'm wondering if that's why only the last character is being checked. Funnily enough, if the "$" is the last character of an argument (i.e. end of line or followed by whitespace), it doesn't need to be escaped:
Code: Select all
root@beyonwizv2:~# a=yyy
root@beyonwizv2:~# echo xxx$ zzz
xxx$ zzz
root@beyonwizv2:~# echo xxx$a zzz
xxxyyy zzz
root@beyonwizv2:~#
arg = "'" + arg.replace("'", "'\\''") + "'".