简体   繁体   English

如何防止GET方法在URI中编码HTML特殊字符?

[英]How do I prevent the GET method from encoding HTML special characters in the URI?

I have a form using the GET method. 我有一个使用GET方法的表单。 If values are submitted with special characters, they appear in the URI as: ?value=fudge%20and%20stuff 如果使用特殊字符提交值,则这些值将在URI中显示为:?value = fudge%20and%20stuff

How do I make it clean? 如何清洁? I don't want to use the header function because this is happening within a page in drupal. 我不想使用标头函数,因为这在drupal的页面内发生。

A URL cannot contain spaces and many other "special characters", therefore they get encoded. URL不能包含空格和许多其他“特殊字符”,因此它们会被编码。 Unfortunately there isn't a lot you can do about it. 不幸的是,您对此无能为力。 The most you could do is some JavaScript trickery in the form, but I don't think it's worth it. 您最多可以做的是在表单中进行一些JavaScript欺骗,但是我认为这样做不值得。

If %20 bothers you, you can substitute (GREP replace) the + character ( ?value=fudge+and+stuff ) for better readability. 如果%20困扰您,则可以替换(GREP替换)+字符( ?value=fudge+and+stuff )以提高可读性。 Otherwise there's not a lot you can do. 否则,您无能为力。 Other "exotic" characters will be similarly escaped, and need to be. 其他“异国”字符也将类似地转义,并且需要保留。

URL :?value=fudge%20and%20stuff URL:?value = fudge%20and%20stuff

Encoded as: fulg< space > and < space >stuff 编码为: fulg< space >< space >stuff

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM