0

I am trying to parse a POST request that includes "\n" and "\t" characters but as soon as I use a Request.Form to manipulate the data, those characters are no longer there. I used Wireshark to confirm that the characters are in the POST.

Can anyone please help?

Here is some code that reproduces the problem:

POST:

str = "accountRequest=<NewUser>" & vbLf & _
"Hello" & vbTab & "World" & vbLf & _
"</NewUser>"


Set objHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
objHTTP.open "POST", "service.asp", False 
objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
objHTTP.send str

response.Write(objHTTP.responseText)

Set objHTTP = Nothing

service.asp:

function w (str)
response.Write(str & "<br>")
end function

str = request.Form("accountRequest")

w(str)
w("Tabs: "& InStr(str,vbTab))
w("Lines: "& InStr(str,vbLf))

output:

HelloWorld
Tabs: 0
Lines: 0
greener
  • 4,989
  • 13
  • 52
  • 93

2 Answers2

1

Finally figured out that classic ASP Request.Form method doesn't preserve tabs if they're in the "\t" format (as opposed to URL encoded). However, PHP's $_POST does and so does the ASP.NET request method.

greener
  • 4,989
  • 13
  • 52
  • 93
0

If all you're trying to do is provide a delimiter to the data being passed via the querystring then I'd try to use a character that is more concrete than tabs and new lines.

| has historically been used a lot for situations like this I believe taht # is another value that makes it through the querystring without many problems.

I, personally, do not like relying on being able to pick Tab and NewLine out of a string value. Too prone to getting lost in certain situations when being passed here and there.

Just do this before sending it:

str = str.replace(VbTab,"#")
str = str.replace(VbLf,"|")

... and then the converse once on your target page and it should work fine.

cavillac
  • 1,311
  • 12
  • 22
  • 1
    I'm not the one sending it. The code I provided above is just a way to replicate the conditions I'm working under. I'm told from the folks who send the data that their method works fine with many other people. – greener Feb 29 '12 at 16:13