【问题标题】:The CGI PATH_INFO variable can really contain control characters?CGI PATH_INFO 变量真的可以包含控制字符吗?
【发布时间】:2015-01-30 02:31:37
【问题描述】:

CGI specification, section 4.1.5,我知道了:

PATH_INFO = "" | ( "/" path )
path      = lsegment *( "/" lsegment )
lsegment  = *lchar
lchar     = <any TEXT or CTL except "/">

TEXTCTL 在上面的规范中定义:

CTL           = <any control character>
TEXT          = <any printable character>

现在问题来了,如何控制PATH_INFO中的字符?

既然PATH_INFO是www服务器根据用户输入的URI填充的,那么我们如何在浏览器中输入控制字符呢?

【问题讨论】:

    标签: php apache nginx cgi


    【解决方案1】:

    百分比编码可用于在 URL 中输入任何字符:

    http://www.example.com/foo%03bar.html
    

    这将在foobar 之间有一个Ctl-c 字符。

    【讨论】:

    • 这么快的回复!非常感谢!对不起,我能再打扰你一次吗?你能解释一下""的PATH_INFO和“/”的区别吗,因为规范说A PATH_INFO of "/" represents a single void path segment.
    • 而且,规范声明Unlike a URI path, the PATH_INFO is not URL-encoded, and cannot contain path-segment parameters.,所以如果 PATH_INFO 不是 URL 编码的,它怎么能包含转义的控制字符?
    • 抱歉,我不知道你是如何得到一个空字符串的。当我用谷歌搜索“empty path_info cgi”时,大部分点击都是关于 ColdFusion 10 中的一个问题,它忽略了这一点。
    • 意思是它是对URL编码的字符进行解码的结果,它不包含原始编码。请参阅PATH_INFO_TRANSLATED 部分中的示例。
    猜你喜欢
    • 2011-08-07
    • 2012-09-10
    • 1970-01-01
    • 1970-01-01
    • 2020-10-26
    • 2015-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多