Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML: prevent url-encoding of POST form

I have an HTML form which must be posted to a URL. I would like the form to POST one variable named DATA like so:

DATA: somevar=someval&somevar2=someotherval

I'm having trouble doing this. It seems by default, forms urlencode the data, resulting in:

DATA: somevar%3Dsomeval%26somevar2%3Dsomeotherval

Changing the form's enc-type to "text/plain" results in:

DATA: somevar=someval
SOMEVAR2: someotherval

Is there any way I can have a form actually just send the data as above?

like image 622
Mala Avatar asked Jan 21 '23 09:01

Mala


1 Answers

I am unsure what your goal is with this post, nor whether preventing URL-encoding of POST form will indeed solve your problems.

But indeed, preventing the URL encoding of the form is 100% possible, simply add the

enctype="text/plain"

attribute to the form.

Below is an example of a request without enctype text/plain and another one with it.

LMint-PC droope # nc -kl 80
POST / HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 168

%7B%22JobTypeIdentifier%22%3A3%2C%22ScheduledStart%22%3Anull%2C%22ScheduleType%22%3A%22Recurring%22%2C%22JobInputP
meters%22%3A%5B%5D%2C%22ignoreParam%22%3A%22=%22%7D^C
LMint-PC droope # ^C
LMint-PC droope # nc -kl 80
POST / HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Type: text/plain
Content-Length: 116

{"JobTypeIdentifier":3,"ScheduledStart":null,"ScheduleType":"Recurring","JobInputParameters":[],"ignoreParam":"="}
like image 95
Pedro Avatar answered Jan 31 '23 03:01

Pedro