一个 url 资源是一个点 (%2E) [英] A url resource that is a dot (%2E)

查看:29
本文介绍了一个 url 资源是一个点 (%2E)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 资源.这意味着我的网址如下所示:http://myapp/index/.我需要添加查询参数,使其看起来像这样:http://myapp/index/.?type=xml我使用 Freemarker 来展示我的资源,并为此案例进行了百分比编码:

I have a resource that is a . This means my url looks like this: http://myapp/index/. And i need to add query parameters so that it looks like this: http://myapp/index/.?type=xml I use Freemarker for the presentation of my resources and made a percent-encoding hack for this case:

<#if key?matches("\.")>
<li><a href="${contextPath}/index/%2E">${key}</a></li>
</#if>

这适用于 Firefox.但所有其他浏览器,如 IE、Safari、Chrom、Opera 只是忽略我的 url 编码点 (http://myapp/index/%2E).

This works fine for Firefox. But all other Browsers like IE, Safari, Chrom, Opera just ignore my url encoded dot (http://myapp/index/%2E).

有什么建议吗?

推荐答案

其实在标准中并没有真正明确说明(RFC 3986) 无论 ... 的百分比编码版本是否应该具有相同的 this-folder/up-a-文件夹的意思是未转义的版本.3.3节只讲了路径段...",没有说明它们是否匹配...code> 在 pct-encoding 之前或之后.

It's actually not really clearly stated in the standard (RFC 3986) whether a percent-encoded version of . or .. is supposed to have the same this-folder/up-a-folder meaning as the unescaped version. Section 3.3 only talks about "The path segments . and ..", without clarifying whether they match . and .. before or after pct-encoding.

我个人认为 Firefox 的解释是 %2E 并不意味着 . 最实用,但不幸的是所有其他浏览器都不同意.这意味着您不能拥有仅包含 ....

Personally I find Firefox's interpretation that %2E does not mean . most practical, but unfortunately all the other browsers disagree. This would mean that you can't have a path component containing only . or ...

我认为唯一可能的建议是不要那样做"!还有其他路径组件也很麻烦,通常是由于服务器限制:路径中的 %2F%00%5C 序列也可能被一些网络服务器屏蔽,空的路径段也会导致问题.因此,通常不可能将所有可能的字节序列放入路径组件中.

I think the only possible suggestion is "don't do that"! There are other path components that are troublesome too, typically due to server limitations: %2F, %00 and %5C sequences in paths may also be blocked by some web servers, and the empty path segment can also cause problems. So in general it's not possible to fit all possible byte sequences into a path component.

这篇关于一个 url 资源是一个点 (%2E)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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