簡體   English   中英

W3C錯誤驗證 - 元素a上屬性href的錯誤值:查詢中的非法字符:不是URL代碼點

[英]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&amp;moduleID=109&amp;no_rooms=2&amp;parks=Central,East&amp;rooms=1,39&amp;weeks=1,3,5,7,9,11,13,15&amp;day=1&amp;semester=1&amp;start_time=09:00&amp;end_time=10:00&amp;length=1&amp;students=100&amp;type=Lecture&amp;Priority=N&amp;metaID=&amp;comments=Crappy Booking&amp;status=1&amp;round=1&amp;date_submitted=2015-02-16 05:01:17&amp;year=2015/2016&amp;" title="This is a link edit the booking"><i class="fa fa-edit"></i></a>

該鏈接由PHP生成; 現在如果不允許使用逗號,我可以進行替換,但我不確定是否允許使用這種格式。

有什么我想念的,因為它看起來很好嗎?

查詢字符串中的空格導致錯誤。 在您的示例中,它們出現在兩個地方: comments=Crappy Bookingdate_submitted=2015-02-16 05:01:17

根據驗證程序的建議,將空格URL編碼為%20 ,允許您的標記驗證:

<a href="/edit_booking.php? ... &amp;comments=Crappy%20Booking&amp;status=1&amp;round=1&amp;date_submitted=2015-02-16%2005:01:17&amp;year=2015/2016&amp;" title="This is a link edit the booking"><i class="fa fa-edit"></i></a>

嘗試對href屬性中傳遞的URL執行escape()

使用PHPrawurlencode將為您完成工作(百分比編碼)。

空格將編碼為%20RFC 3986 )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM