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

查看:328
本文介绍了一个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 )百分比编码版本的 .. 应该是相同的这个文件夹/ up-a-folder意思是未转义的版本。第3.3节仅谈论路径段 .. ,而不用说明它们是否匹配<$ c $在pct编码之前或之后,c>。和 ..

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 路径中的序列也可能被某些Web服务器阻止,空路径段也可能导致问题。因此,一般来说,不可能将所有可能的字节序列适用于路径组件。

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天全站免登陆