\0 Being added on to string?
I have a WCF service that takes text a customer enters and passes it to a windows service. I am using jQuery to send the text to the WCF service (in json). Before passing the data I call $.trim() on the text. Today i received text with a开发者_JAVA技巧 null character in it that looked like this:
00-15-5D-0A-0B-01\0
If I go back and test, and send the text through like a "normal user", the text is properly escaped and sent to the service:
00-15-5D-0A-0B-01\\0
My question is: shouldnt jQuery strip the special character using the Trim() method?
Its strange because I know this customer wasnt trying to be "sneaky" or anything, not to degrade them, but they are just not knowledgeable enough to know about this type of stuff. Which makes me wonder if something happened between the client & server.
Is it possible this character would be tacked on if communication/request was interrupted?
From the jQuery.trim() API documentation:
The $.trim() function removes all newlines, spaces (including non-breaking spaces), and tabs from the beginning and end of the supplied string. If these whitespace characters occur in the middle of the string, they are preserved.
The source code is a fairly straight forward regex
expression that looks for those characters mentioned above.
I don't have experience with jquery so haven't tried this myself, but the documentation and source code shows trim doesn't remove NUL chars. http://api.jquery.com/jQuery.trim/
The source of the extra NUL char is hard to tell without more information.
精彩评论