PHP 脚本中请求 URL 中出现的文档片段
在将 HTTP 请求记录到文件时,我发现了一些我意想不到的东西。
我刚刚将 $_SERVER['REQUEST_URI']
放入日志中。
猜猜我发现了什么,一个带有 #fragment 的 url:
18/05: requested cat/page.html#fragment
注意,在 2477 行日志中,我只发现一行带有片段
每个人都知道(应该)该片段在服务器端永远不知道,但只有 javascript 代码可以获取它。那么这里发生了什么?
我在 Apache 2.X (Debian) 上运行 PHP 5.3。
While logging HTTP requests to a file I have found something I would not expect.
I just put in the log the $_SERVER['REQUEST_URI']
.
Guess what I have found, an url with #fragment attached:
18/05: requested cat/page.html#fragment
Note out of 2477 line of logs I found only one line with fragment attached
Everyone know (should) that fragment is never known server-side but only javascript code can get it. So what is happening here?
I am running PHP 5.3 on Apache 2.X (Debian).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的断言“服务器端永远不知道片段,但只有 javascript 代码才能获取它”有点短视。
虽然在传统浏览器的一般操作中,向服务器发出的请求中确实不包含片段,但没有什么可以阻止我在 HTTP 请求中编写我想要的任何内容。
有人在测试,有人在玩,有人在玩奇怪的黑客尝试,或者有人在使用有缺陷的浏览器。
我不会担心这个。
Your assertion that "fragment is never known server-side but only javascript code can get it" is a little short-sighted.
Whilst it's true that, in general operation with a conventional browser, a fragment is not included in the request-to-server, there is nothing stopping me from writing whatever I want in an HTTP request.
Someone's testing, someone's playing, someone's playing a bizarre hack attempt, or someone's using a buggy browser.
I wouldn't worry about it.