[英]W3C error validating - Bad value for attribute href on element a: Illegal character in query: not a URL code point
我得到屬性值差href
元素a
:在查詢非法字符:不是W3C的URL代碼點具有以下a
標簽:
<a href="/edit_booking.php?requestID=84&moduleID=109&no_rooms=2&parks=Central,East&rooms=1,39&weeks=1,3,5,7,9,11,13,15&day=1&semester=1&start_time=09:00&end_time=10:00&length=1&students=100&type=Lecture&Priority=N&metaID=&comments=Crappy Booking&status=1&round=1&date_submitted=2015-02-16 05:01:17&year=2015/2016&" title="This is a link edit the booking"><i class="fa fa-edit"></i></a>
該鏈接由PHP生成; 現在如果不允許使用逗號,我可以進行替換,但我不確定是否允許使用這種格式。
有什么我想念的,因為它看起來很好嗎?
查詢字符串中的空格導致錯誤。 在您的示例中,它們出現在兩個地方: comments=Crappy Booking
和date_submitted=2015-02-16 05:01:17
。
根據驗證程序的建議,將空格URL編碼為%20
,允許您的標記驗證:
<a href="/edit_booking.php? ... &comments=Crappy%20Booking&status=1&round=1&date_submitted=2015-02-16%2005:01:17&year=2015/2016&" title="This is a link edit the booking"><i class="fa fa-edit"></i></a>
嘗試對href屬性中傳遞的URL執行escape()
。
使用PHP , rawurlencode
將為您完成工作(百分比編碼)。
空格將編碼為%20
( RFC 3986 )。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.