I have a string of format : "javascript:alert('XSS')"
I use a dictionary(There is alot of other stuff in dictionary ) whose key is &#x and its corresponding value as \x Something like dict = {'&#x':'\\x'}
I then replaces the key with values : The string becomes like : \x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3A\x61\x6C\x65\x72\x74\x28\x27\x58\x53\x53\x27\x29
Ideally this should be converted to its original ascii form which is javascript:alert('XSS') when I print.
I have to explicitly use unhexlify(hexstring) to get this converted to give converted form.
However if I manually write : a new variable with var1 = "\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3A\x61\x6C\x65\x72\x74\x28\x27\x58\x53\x53\x27\x29"
And then print this var1 it gives me javascript:alert('XSS') as result.
Why is that extra step of conversion required? Is there any other way to get rid of that extra call of unhexlify.