2013-02-05 34 views
3

我屏蔽了以下URL中的所有特殊字符,但w3c-validator仍會拋出錯誤。 我檢查了所有的NFC教程,但我不知道錯誤在哪裏。任何想法 ?HTML5驗證錯誤一個href(NFC)

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> 

的URL

<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> 

語法IRI引用

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

回答

3

字符s []需要在URL中編碼%,如%5B%5D,根據STD 66(其中附錄A包含語法摘要,顯示括號是「gen-delims」字符,這在查詢部分中是不允許的除了%編碼)。

你應該發佈一個HTML文檔,因爲這就是驗證器的工作原理。下面的測試文檔(這驗證)包括你提到的網址,正確編碼:

<!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> 

從這個且不說,該網址無法正常工作;它會導致一個「多重選擇」響應,這很奇怪(當服務器正在進行一些沒有找到可接受的備選方案的內容協商時應該發出這樣的消息,並且應該提供一個備選方案列表;但是這裏更多或者少一個「未找到」情況)。

+0

Perfekt,非常感謝! – user2044658