Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a bug in System.Web.HttpUtility.UrlDecode?

Consider the following line of code:

string _decoded = System.Web.HttpUtility.UrlDecode(
  "There%20should%20be%20text%20after%20this%0022help!");

The encoded line

"There%20should%20be%20text%20after%20this%0022help!" 

when decoded via the website urldecoder.org produces

"There should be text after this22help!"

however the value of _decoded as displayed in the debugger is: Figure 1: Debugger view of problem

What could be causing this problem? Is there a setting or special encoding that will circumvent this in all cases?

EDIT: Yes, I consider this behavior to be an error. I don't want URLDecode to introduce the \0 char to the resultant string, because it would result in an invalid file name (my code is moving around files).

like image 839
user77232 Avatar asked Apr 19 '26 03:04

user77232


1 Answers

There is a null byte (\0 = %00) after this so the debugger doesn't show the rest of the string.

So the decoded value is correct, it's just the limitation (or bug?) of the debugger.

You can take a look at here for more info about null byte from security perspective. And there is this question posted about it as well.

like image 189
Selman Genç Avatar answered Apr 21 '26 16:04

Selman Genç