I have a block of code:
temp = "Cancel"
puts CGI::escape(words[1])
puts "\n"
puts CGI::escape(temp)
puts "\n"
puts words[1]
puts "\n"
puts temp
puts "\n"
My output is:
%00C%00a%00n%00c%00e%00l%00
Cancel
Cancel
Cancel
I think it’s fair to assume that the issue here is the way I set up my words array. However, I was wondering if this is common behavior which has a solution? If not, what could I be doing wrong that would cause this?
My words array is set up by reading data from a file, then splitting each line and extracting the information I need, so it’s nothing too complex.
You have NUL bytes in your string.
putsjust ignores them.with inspect you can see them:
and here the output of
CGI::escapeedit:
The quick and dirty solution would be to just remove them:
but as you have NUL bytes in front of every char, you should better check your code for reading the file. If you’d provide the code, it would be easier to come up with a solution.