如何阻止HTTP转义引号? [英] How can I stop HTTP from escaping quotes?

查看:562
本文介绍了如何阻止HTTP转义引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在POST数据中发送了一个JSON格式的对象到服务器。

我使用C#将一些数据发布到运行PHP的web服务器。 / p>

当它离开C#程序时,数据看起来像这样:

  json_text = {abc:hello,dfg:world} 

I请使用 echo $ _POST ['json_text']; 输入以下内容:

<$ p $ {\abc \:\hello \,\dfg \:\world\}

我不太了解POST数据如何打包到HTTP数据包中。我打开WireShark查看POST数据中的引用是如何发送的,它看起来像是被%22 所取代。然而,我尝试用%22取代我的引号,并且它不会阻止引号在输出时被转义。



谢谢

解决方案

关闭PHP的 magic_quotes 选项。这可能是反斜杠的来源。


I'm using C# to POST some data to a webserver running PHP.

I'm sending a JSON formatted object to the server in the POST data.

The data looks something like this when it leaves the C# program:

json_text={"abc":"hello", "dfg":"world"}

I have the server printing the data exactly as it received it using echo $_POST['json_text']; The script outputs the following:

{\"abc\":\"hello\", \"dfg\":\"world\"}

I'm not very familiar with how POST data is packaged into an HTTP packet. I opened up WireShark to look at how quotes are sent in POST data and it looks like they are replaced with %22. However, I tried replacing my quotes with %22 and it did NOT stop the quotes from being escaped when it is outputted.

Thank you

解决方案

Turn off PHP's magic_quotes option. That's probably where the backslashes are coming from.

这篇关于如何阻止HTTP转义引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆