tomek-o / tSIP

SIP softphone
149 stars 32 forks source link

Script = cannot run #28

Closed notehel closed 3 years ago

notehel commented 3 years ago

I found that when using “SCRIPT=” parameter, it will be unable to run because of special characters. I changed the script to Base64. I don't know if it is correct.

tSIP/FormMain.cpp

RunScript(SCRIPT_SRC_COMMAND_LINE, 0, cmd.script, breakReq, handled);

std::string scriptCotent = base64_decode(cmd.script.c_str(), BASE64_ALPHABET_FSAFE); RunScript(SCRIPT_SRC_COMMAND_LINE, 0, scriptCotent.c_str(), breakReq, handled);

tomek-o commented 3 years ago

Could you provide some minimal script example? If base64 works for you and seems to be viable last resort option, maybe I should add something like SCRIPT_B64 as fallback option and maybe option to export script to filesafe-base64 from script editor window. I'm assuming you are compiling your own executable at the moment.

notehel commented 3 years ago

SCRIPT=UpdateSettings('{"Accounts":[{"reg_server" : "192.168.0.100"}]}') This doesn't work

After modification SCRIPT=VXBkYXRlU2V0dGluZ3MoJ3siQWNjb3VudHMiOlt7InJlZ19zZXJ2ZXIiIDogIjE5Mi4xNjguMC4xMDAifV19Jyk=

notehel commented 3 years ago

I've modified it and compiled it. It can be used. I just don't know if it's right.

tomek-o commented 3 years ago

I've tried escaping double quotes from command line but I've failed despite reading seemingly clear instruction from stackoverflow.

I've modified it and compiled it. It can be used. I just don't know if it's right.

Whatever works for you. I've opted though for additional (keeping backward compatibility) SCRIPT_B64= parameter type and basic base64 encoding (BASE64_ALPHABET_BASIC) as it may be easier to find (e.g. online) and less popular filesystem-safe variant does not seem to be necessary. Accidentally base64 and filesystem-safe base64 seem to be identical for your example. This is included in https://github.com/tomek-o/tSIP/commit/0ccdb041c1fb08a02b88e68cf88320a98c8ff8eb and in http://tomeko.net/tmp/tSIP.exe.