开发者

POSTing XML via HTML Forms

开发者 https://www.devze.com 2022-12-21 00:00 出处:网络
I am developing a web and want to make it so that the user can create some stuff POSTing XML data. For that purpose there is a <textarea> where the user can write (copy/paste) XML a开发者_StackO

I am developing a web and want to make it so that the user can create some stuff POSTing XML data. For that purpose there is a <textarea> where the user can write (copy/paste) XML a开发者_StackOverflow中文版nd submit it. The problem is that I am losing data: characters such as <, >, and I think others too, get lost.

Maybe it is a framework problem, not sure, I am using Elgg and receiving the data with get_input().

UPDATE1: some code answering the comment:

<form method="POST" action="http://for.bar/slash" enctype="text/xml">
<input name="add" type="submit" value="Create"  />
</form> 

to receive the data I use elgg get_input()

$data = get_input('data');


If i where to make a wild guess I'd say that there is some kind of auto-magical xss protection being used by get_input(). You could try doing a print_r($_POST); or perhaps elgg is "sanitizing" all of $_POST as well. In this case you may have to base64 encode the data with JavaScript before submitting the request.


According to MDN, the only standard values that should be used in form's enctype attribute are following:

  • application/x-www-form-urlencoded
  • multipart/form-data
  • text/plain

That being said, you can run into unpredictable situations having it to have value application/xml.

Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form#attr-enctype

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号