【问题标题】:HTML5 validation error a href (NFC)HTML5 验证错误 a href (NFC)
【发布时间】:2013-01-20 22:51:21
【问题描述】:

我屏蔽了以下 URL 中的所有特殊字符,但 w3c-validator 仍然抛出错误。 我检查了所有 NFC 教程,但我不知道错误在哪里。有什么想法吗?

网址

<a href="http://www.example.de/index.php&#63;cnid&#61;efcb9a458fb823ba877ef53b7162598f&#38;ldtype&#61;grid&#38;cl&#61;alist&#38;tpl&#61;&#38;fnc&#61;executefilter&#38;fname&#61;&#38;attrfilter&#91;3a5d1ca314a5205fa7b7b3baa5d2f94e&#93;&#91;2f143d22ce421269b5c7d01a160f6541&#93;&#61;2f143d22ce421269b5c7d01a160f6541">Asche</a>

w3c-错误

Line 618, Column 441: Bad value http://www.example.de/index.php?cnid=efcb9a458fb823ba877ef53b7162598f&ldtype=grid&cl=alist&tpl=&fnc=executefilter&fname=&attrfilter[3a5d1ca314a5205fa7b7b3baa5d2f94e][2f143d22ce421269b5c7d01a160f6541]=2f143d22ce421269b5c7d01a160f6541 for attribute href on element a: Illegal character in query component.

…21269b5c7d01a160f6541&#93;&#61;2f143d22ce421269b5c7d01a160f6541">Asche</a></li>

IRI 引用的语法

Any URL. For example: /hello, #canvas, or http://example.org/. Characters should be represented in NFC and spaces should be escaped as %20. 

【问题讨论】:

    标签: html validation character href


    【解决方案1】:

    [] 字符需要在 URL 中进行 % 编码,如 %5B%5D,根据 STD 66(其中附录 A 包含语法摘要,显示括号为“ gen-delims” 字符,不允许在查询部分中使用,除非是 %-encoded)。

    你应该已经发布了一个 HTML 文档,因为这是验证器的工作。以下测试文档(验证)包含您提到的正确编码的 URL:

    <!doctype html>
    <meta charset=utf-8>
    <title></title>
    <a href=
    "http://www.example.de/index.php?cnid=efcb9a458fb823ba877ef53b7162598f&amp;ldtype=grid&amp;cl=alist&amp;tpl=&amp;fnc=executefilter&amp;fname=&amp;attrfilter%5B3a5d1ca314a5205fa7b7b3baa5d2f94e%5D%5B2f143d22ce421269b5c7d01a160f6541%5D=2f143d22ce421269b5c7d01a160f6541">foo</a>
    

    除此之外,URL 不起作用;它会导致“Multiple Choices”响应,这很奇怪(当服务器正在执行一些找不到可接受的替代方案的内容协商时,应该发出这样的消息,并且应该提供替代方案列表;但这里更多或少一个“未找到”的情况)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-10
      • 1970-01-01
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 2014-01-25
      • 2021-09-27
      • 1970-01-01
      相关资源
      最近更新 更多