URL 解码未按预期工作
我的浏览器显示文件名为
http://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0%2C1%25.pdf
实际文件名为 204160_20090604_Atropine_DCB_oogdruppels_0,5%.pdf
urldecode 后,它给出错误的文件名 <代码> http://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0,1%.pdf
更新:
最初我以为是 URL 解码的问题,但是像名称 204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1,2%.pdf
这样的文件在浏览器中渲染时会抛出错误请求。我正在使用 Kohana 3 框架。和服务器有关系吗?
My Browser shows URL with file name as
http://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0%2C1%25.pdf
Actual File name is 204160_20090604_Atropine_DCB_oogdruppels_0,5%.pdf
After urldecode, it gives wrong file name as
http://www.example.com/pdf/204177_20090604_Chloorhexidine_DCB_oogdruppels_0,1%.pdf
Update:
Initially I thought that its problem of URL Decode, but files like name 204153_20090605_Aluminiumacetotartraat_DCB_oordruppels_1,2%.pdf
while rendering in browser throws Bad request. I am using Kohana 3 framwork. Is it related with server?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一切都好。你的错误在其他地方。
All ok. You're error is somewhere else.
您正在查看两个不同的文件。
无法将
204160_20090604_Atropine_DCB_oogdruppels_
编码为204177_20090604_Chloorhexidine_DCB_oogdruppels_
,编码不会更改字母字符。该错误很可能出现在创建文件列表并输出链接的代码中;链接标题和文件名之间的映射似乎很混乱。
You are looking at two different files.
It's not possible to urlencode
204160_20090604_Atropine_DCB_oogdruppels_
into204177_20090604_Chloorhexidine_DCB_oogdruppels_
, encoding does not change alphabetical characters.The error is most likely in the code that creates the file list and outputs the links; the mapping between link titles and filenames appears to be messed up.
这将为您使用 c# 提供准确的文件名 m
, (逗号) 编码为 %2c
如果您使用
Request.Url
,%(百分比)会被浏览器编码为 %25,它将解码 ,(逗号),但不会解码 %(百分比),
因此 Server.UrlDecode("xyz") 会解码所有字符除了%(百分比),那就是上面的文件名中有“%25”
this will give you exact file name m using c#
, (comma) is encoded as %2c
% (percent) is encoded as %25 by browsers
if you use
Request.Url
it'll decode ,(comma) but not %(percent)So Server.UrlDecode("xyz") decode all characters except %(percent), thats y there's "%25" in the above filename