kvirc / KVIrc

The KVIrc IRC Client
http://www.kvirc.net/
GNU General Public License v2.0
240 stars 75 forks source link

$ASCIITOHEX error #2500

Closed CW-151 closed 3 years ago

CW-151 commented 3 years ago

Greetings, I am having an issue with encryption, but I believe it to be a KVirc issue, rather than with encryption. The following code causes an error because the encryption key contains "$" which is a reserved word almost everywhere.

if ($chan.name == "#tst") { window.setCryptEngine $window Mircryption $asciitohex("old:H23n$hw63NDHw134kYES") $asciitohex("H23n$hw63NDHw134kYES") } RESULT: 15:40:39] [KVS] Runtime error: Call to undefined function 'hw63NDHw134kYES' [15:40:39] [KVS] In script context "OnChannelWindowCreated::Fillers_Encryption", line 2, near character 66 [15:40:39] Event handler OnChannelWindowCreated::Fillers_Encryption is broken: disabling

How can this be resolved? In the mean time, i have to enter the encryption keys(both of them) manually. :(

Ionic commented 3 years ago

Not a bug.

Escape the characters % and $ as in $asciitohex("old:H23n\$hw63NDHw134kYES").

There is also an $escape function, but I don't know if it'll work for literal strings.

You could try something like $asciitohex($escape("old:H23n$hw63NDHw134kYES")), but if that doesn't work, you'll need to manually escape the mentioned characters. (Note that % is also special.)

CW-151 commented 3 years ago

Ionic, I read a bit more on the $escape function, It also mentions an escape character (\), which ended up doing the job. The $escape() function did not produce the correct result. Thanks for your tip!

Ionic commented 3 years ago

$escape() should automatically escape characters in a given string, yeah.

However, for literal strings, the parser tries to evaluate the literal string before it's passed to the function, which will be useless to your use case. That's why I assumed that it would fail in your case.

Closing up.