setters_tests.json 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564
  1. {
  2. "comment": [
  3. "# Pulled from https://github.com/web-platform-tests/wpt/blob/876fe001f2279b96e7c6b9e8970dc92c484835ff/url/resources/setters_tests.json",
  4. "## Tests for setters of https://url.spec.whatwg.org/#urlutils-members",
  5. "",
  6. "This file contains a JSON object.",
  7. "Other than 'comment', each key is an attribute of the `URL` interface",
  8. "defined in WHATWG’s URL Standard.",
  9. "The values are arrays of test case objects for that attribute.",
  10. "",
  11. "To run a test case for the attribute `attr`:",
  12. "",
  13. "* Create a new `URL` object with the value for the 'href' key",
  14. " the constructor single parameter. (Without a base URL.)",
  15. " This must not throw.",
  16. "* Set the attribute `attr` to (invoke its setter with)",
  17. " with the value of for 'new_value' key.",
  18. "* The value for the 'expected' key is another object.",
  19. " For each `key` / `value` pair of that object,",
  20. " get the attribute `key` (invoke its getter).",
  21. " The returned string must be equal to `value`.",
  22. "",
  23. "Note: the 'href' setter is already covered by urltestdata.json."
  24. ],
  25. "protocol": [
  26. {
  27. "comment": "The empty string is not a valid scheme. Setter leaves the URL unchanged.",
  28. "href": "a://example.net",
  29. "new_value": "",
  30. "expected": {
  31. "href": "a://example.net",
  32. "protocol": "a:"
  33. }
  34. },
  35. {
  36. "href": "a://example.net",
  37. "new_value": "b",
  38. "expected": {
  39. "href": "b://example.net",
  40. "protocol": "b:"
  41. }
  42. },
  43. {
  44. "href": "javascript:alert(1)",
  45. "new_value": "defuse",
  46. "expected": {
  47. "href": "defuse:alert(1)",
  48. "protocol": "defuse:"
  49. }
  50. },
  51. {
  52. "comment": "Upper-case ASCII is lower-cased",
  53. "href": "a://example.net",
  54. "new_value": "B",
  55. "expected": {
  56. "href": "b://example.net",
  57. "protocol": "b:"
  58. }
  59. },
  60. {
  61. "comment": "Non-ASCII is rejected",
  62. "href": "a://example.net",
  63. "new_value": "é",
  64. "expected": {
  65. "href": "a://example.net",
  66. "protocol": "a:"
  67. }
  68. },
  69. {
  70. "comment": "No leading digit",
  71. "href": "a://example.net",
  72. "new_value": "0b",
  73. "expected": {
  74. "href": "a://example.net",
  75. "protocol": "a:"
  76. }
  77. },
  78. {
  79. "comment": "No leading punctuation",
  80. "href": "a://example.net",
  81. "new_value": "+b",
  82. "expected": {
  83. "href": "a://example.net",
  84. "protocol": "a:"
  85. }
  86. },
  87. {
  88. "href": "a://example.net",
  89. "new_value": "bC0+-.",
  90. "expected": {
  91. "href": "bc0+-.://example.net",
  92. "protocol": "bc0+-.:"
  93. }
  94. },
  95. {
  96. "comment": "Only some punctuation is acceptable",
  97. "href": "a://example.net",
  98. "new_value": "b,c",
  99. "expected": {
  100. "href": "a://example.net",
  101. "protocol": "a:"
  102. }
  103. },
  104. {
  105. "comment": "Non-ASCII is rejected",
  106. "href": "a://example.net",
  107. "new_value": "bé",
  108. "expected": {
  109. "href": "a://example.net",
  110. "protocol": "a:"
  111. }
  112. },
  113. {
  114. "comment": "Can’t switch from URL containing username/password/port to file",
  115. "href": "http://test@example.net",
  116. "new_value": "file",
  117. "expected": {
  118. "href": "http://test@example.net/",
  119. "protocol": "http:"
  120. }
  121. },
  122. {
  123. "href": "https://example.net:1234",
  124. "new_value": "file",
  125. "expected": {
  126. "href": "https://example.net:1234/",
  127. "protocol": "https:"
  128. }
  129. },
  130. {
  131. "href": "wss://x:x@example.net:1234",
  132. "new_value": "file",
  133. "expected": {
  134. "href": "wss://x:x@example.net:1234/",
  135. "protocol": "wss:"
  136. }
  137. },
  138. {
  139. "comment": "Can’t switch from file URL with no host",
  140. "href": "file://localhost/",
  141. "new_value": "http",
  142. "expected": {
  143. "href": "file:///",
  144. "protocol": "file:"
  145. }
  146. },
  147. {
  148. "href": "file:///test",
  149. "new_value": "https",
  150. "expected": {
  151. "href": "file:///test",
  152. "protocol": "file:"
  153. }
  154. },
  155. {
  156. "href": "file:",
  157. "new_value": "wss",
  158. "expected": {
  159. "href": "file:///",
  160. "protocol": "file:"
  161. }
  162. },
  163. {
  164. "comment": "Can’t switch from special scheme to non-special",
  165. "href": "http://example.net",
  166. "new_value": "b",
  167. "expected": {
  168. "href": "http://example.net/",
  169. "protocol": "http:"
  170. }
  171. },
  172. {
  173. "href": "file://hi/path",
  174. "new_value": "s",
  175. "expected": {
  176. "href": "file://hi/path",
  177. "protocol": "file:"
  178. }
  179. },
  180. {
  181. "href": "https://example.net",
  182. "new_value": "s",
  183. "expected": {
  184. "href": "https://example.net/",
  185. "protocol": "https:"
  186. }
  187. },
  188. {
  189. "href": "ftp://example.net",
  190. "new_value": "test",
  191. "expected": {
  192. "href": "ftp://example.net/",
  193. "protocol": "ftp:"
  194. }
  195. },
  196. {
  197. "comment": "Cannot-be-a-base URL doesn’t have a host, but URL in a special scheme must.",
  198. "href": "mailto:me@example.net",
  199. "new_value": "http",
  200. "expected": {
  201. "href": "mailto:me@example.net",
  202. "protocol": "mailto:"
  203. }
  204. },
  205. {
  206. "comment": "Can’t switch from non-special scheme to special",
  207. "href": "ssh://me@example.net",
  208. "new_value": "http",
  209. "expected": {
  210. "href": "ssh://me@example.net",
  211. "protocol": "ssh:"
  212. }
  213. },
  214. {
  215. "href": "ssh://me@example.net",
  216. "new_value": "https",
  217. "expected": {
  218. "href": "ssh://me@example.net",
  219. "protocol": "ssh:"
  220. }
  221. },
  222. {
  223. "href": "ssh://me@example.net",
  224. "new_value": "file",
  225. "expected": {
  226. "href": "ssh://me@example.net",
  227. "protocol": "ssh:"
  228. }
  229. },
  230. {
  231. "href": "ssh://example.net",
  232. "new_value": "file",
  233. "expected": {
  234. "href": "ssh://example.net",
  235. "protocol": "ssh:"
  236. }
  237. },
  238. {
  239. "href": "nonsense:///test",
  240. "new_value": "https",
  241. "expected": {
  242. "href": "nonsense:///test",
  243. "protocol": "nonsense:"
  244. }
  245. },
  246. {
  247. "comment": "Stuff after the first ':' is ignored",
  248. "href": "http://example.net",
  249. "new_value": "https:foo : bar",
  250. "expected": {
  251. "href": "https://example.net/",
  252. "protocol": "https:"
  253. }
  254. },
  255. {
  256. "comment": "Stuff after the first ':' is ignored",
  257. "href": "data:text/html,<p>Test",
  258. "new_value": "view-source+data:foo : bar",
  259. "expected": {
  260. "href": "view-source+data:text/html,<p>Test",
  261. "protocol": "view-source+data:"
  262. }
  263. },
  264. {
  265. "comment": "Port is set to null if it is the default for new scheme.",
  266. "href": "http://foo.com:443/",
  267. "new_value": "https",
  268. "expected": {
  269. "href": "https://foo.com/",
  270. "protocol": "https:",
  271. "port": ""
  272. }
  273. },
  274. {
  275. "comment": "Tab and newline are stripped",
  276. "href": "http://test/",
  277. "new_value": "h\u000D\u000Att\u0009ps",
  278. "expected": {
  279. "href": "https://test/",
  280. "protocol": "https:",
  281. "port": ""
  282. }
  283. },
  284. {
  285. "href": "http://test/",
  286. "new_value": "https\u000D",
  287. "expected": {
  288. "href": "https://test/",
  289. "protocol": "https:"
  290. }
  291. },
  292. {
  293. "comment": "Non-tab/newline C0 controls result in no-op",
  294. "href": "http://test/",
  295. "new_value": "https\u0000",
  296. "expected": {
  297. "href": "http://test/",
  298. "protocol": "http:"
  299. }
  300. },
  301. {
  302. "href": "http://test/",
  303. "new_value": "https\u000C",
  304. "expected": {
  305. "href": "http://test/",
  306. "protocol": "http:"
  307. }
  308. },
  309. {
  310. "href": "http://test/",
  311. "new_value": "https\u000E",
  312. "expected": {
  313. "href": "http://test/",
  314. "protocol": "http:"
  315. }
  316. },
  317. {
  318. "href": "http://test/",
  319. "new_value": "https\u0020",
  320. "expected": {
  321. "href": "http://test/",
  322. "protocol": "http:"
  323. }
  324. }
  325. ],
  326. "username": [
  327. {
  328. "comment": "No host means no username",
  329. "href": "file:///home/you/index.html",
  330. "new_value": "me",
  331. "expected": {
  332. "href": "file:///home/you/index.html",
  333. "username": ""
  334. }
  335. },
  336. {
  337. "comment": "No host means no username",
  338. "href": "unix:/run/foo.socket",
  339. "new_value": "me",
  340. "expected": {
  341. "href": "unix:/run/foo.socket",
  342. "username": ""
  343. }
  344. },
  345. {
  346. "comment": "Cannot-be-a-base means no username",
  347. "href": "mailto:you@example.net",
  348. "new_value": "me",
  349. "expected": {
  350. "href": "mailto:you@example.net",
  351. "username": ""
  352. }
  353. },
  354. {
  355. "href": "javascript:alert(1)",
  356. "new_value": "wario",
  357. "expected": {
  358. "href": "javascript:alert(1)",
  359. "username": ""
  360. }
  361. },
  362. {
  363. "href": "http://example.net",
  364. "new_value": "me",
  365. "expected": {
  366. "href": "http://me@example.net/",
  367. "username": "me"
  368. }
  369. },
  370. {
  371. "href": "http://:secret@example.net",
  372. "new_value": "me",
  373. "expected": {
  374. "href": "http://me:secret@example.net/",
  375. "username": "me"
  376. }
  377. },
  378. {
  379. "href": "http://me@example.net",
  380. "new_value": "",
  381. "expected": {
  382. "href": "http://example.net/",
  383. "username": ""
  384. }
  385. },
  386. {
  387. "href": "http://me:secret@example.net",
  388. "new_value": "",
  389. "expected": {
  390. "href": "http://:secret@example.net/",
  391. "username": ""
  392. }
  393. },
  394. {
  395. "comment": "UTF-8 percent encoding with the userinfo encode set.",
  396. "href": "http://example.net",
  397. "new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
  398. "expected": {
  399. "href": "http://%00%01%09%0A%0D%1F%20!%22%23$%&'()*+,-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F%C2%80%C2%81%C3%89%C3%A9@example.net/",
  400. "username": "%00%01%09%0A%0D%1F%20!%22%23$%&'()*+,-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F%C2%80%C2%81%C3%89%C3%A9"
  401. }
  402. },
  403. {
  404. "comment": "Bytes already percent-encoded are left as-is.",
  405. "href": "http://example.net",
  406. "new_value": "%c3%89té",
  407. "expected": {
  408. "href": "http://%c3%89t%C3%A9@example.net/",
  409. "username": "%c3%89t%C3%A9"
  410. }
  411. },
  412. {
  413. "href": "sc:///",
  414. "new_value": "x",
  415. "expected": {
  416. "href": "sc:///",
  417. "username": ""
  418. }
  419. },
  420. {
  421. "href": "javascript://x/",
  422. "new_value": "wario",
  423. "expected": {
  424. "href": "javascript://wario@x/",
  425. "username": "wario"
  426. }
  427. },
  428. {
  429. "href": "file://test/",
  430. "new_value": "test",
  431. "expected": {
  432. "href": "file://test/",
  433. "username": ""
  434. }
  435. }
  436. ],
  437. "password": [
  438. {
  439. "comment": "No host means no password",
  440. "href": "file:///home/me/index.html",
  441. "new_value": "secret",
  442. "expected": {
  443. "href": "file:///home/me/index.html",
  444. "password": ""
  445. }
  446. },
  447. {
  448. "comment": "No host means no password",
  449. "href": "unix:/run/foo.socket",
  450. "new_value": "secret",
  451. "expected": {
  452. "href": "unix:/run/foo.socket",
  453. "password": ""
  454. }
  455. },
  456. {
  457. "comment": "Cannot-be-a-base means no password",
  458. "href": "mailto:me@example.net",
  459. "new_value": "secret",
  460. "expected": {
  461. "href": "mailto:me@example.net",
  462. "password": ""
  463. }
  464. },
  465. {
  466. "href": "http://example.net",
  467. "new_value": "secret",
  468. "expected": {
  469. "href": "http://:secret@example.net/",
  470. "password": "secret"
  471. }
  472. },
  473. {
  474. "href": "http://me@example.net",
  475. "new_value": "secret",
  476. "expected": {
  477. "href": "http://me:secret@example.net/",
  478. "password": "secret"
  479. }
  480. },
  481. {
  482. "href": "http://:secret@example.net",
  483. "new_value": "",
  484. "expected": {
  485. "href": "http://example.net/",
  486. "password": ""
  487. }
  488. },
  489. {
  490. "href": "http://me:secret@example.net",
  491. "new_value": "",
  492. "expected": {
  493. "href": "http://me@example.net/",
  494. "password": ""
  495. }
  496. },
  497. {
  498. "comment": "UTF-8 percent encoding with the userinfo encode set.",
  499. "href": "http://example.net",
  500. "new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
  501. "expected": {
  502. "href": "http://:%00%01%09%0A%0D%1F%20!%22%23$%&'()*+,-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F%C2%80%C2%81%C3%89%C3%A9@example.net/",
  503. "password": "%00%01%09%0A%0D%1F%20!%22%23$%&'()*+,-.%2F09%3A%3B%3C%3D%3E%3F%40AZ%5B%5C%5D%5E_%60az%7B%7C%7D~%7F%C2%80%C2%81%C3%89%C3%A9"
  504. }
  505. },
  506. {
  507. "comment": "Bytes already percent-encoded are left as-is.",
  508. "href": "http://example.net",
  509. "new_value": "%c3%89té",
  510. "expected": {
  511. "href": "http://:%c3%89t%C3%A9@example.net/",
  512. "password": "%c3%89t%C3%A9"
  513. }
  514. },
  515. {
  516. "href": "sc:///",
  517. "new_value": "x",
  518. "expected": {
  519. "href": "sc:///",
  520. "password": ""
  521. }
  522. },
  523. {
  524. "href": "javascript://x/",
  525. "new_value": "bowser",
  526. "expected": {
  527. "href": "javascript://:bowser@x/",
  528. "password": "bowser"
  529. }
  530. },
  531. {
  532. "href": "file://test/",
  533. "new_value": "test",
  534. "expected": {
  535. "href": "file://test/",
  536. "password": ""
  537. }
  538. }
  539. ],
  540. "host": [
  541. {
  542. "comment": "Non-special scheme",
  543. "href": "sc://x/",
  544. "new_value": "\u0000",
  545. "expected": {
  546. "href": "sc://x/",
  547. "host": "x",
  548. "hostname": "x"
  549. }
  550. },
  551. {
  552. "href": "sc://x/",
  553. "new_value": "\u0009",
  554. "expected": {
  555. "href": "sc:///",
  556. "host": "",
  557. "hostname": ""
  558. }
  559. },
  560. {
  561. "href": "sc://x/",
  562. "new_value": "\u000A",
  563. "expected": {
  564. "href": "sc:///",
  565. "host": "",
  566. "hostname": ""
  567. }
  568. },
  569. {
  570. "href": "sc://x/",
  571. "new_value": "\u000D",
  572. "expected": {
  573. "href": "sc:///",
  574. "host": "",
  575. "hostname": ""
  576. }
  577. },
  578. {
  579. "href": "sc://x/",
  580. "new_value": " ",
  581. "expected": {
  582. "href": "sc://x/",
  583. "host": "x",
  584. "hostname": "x"
  585. }
  586. },
  587. {
  588. "href": "sc://x/",
  589. "new_value": "#",
  590. "expected": {
  591. "href": "sc:///",
  592. "host": "",
  593. "hostname": ""
  594. }
  595. },
  596. {
  597. "href": "sc://x/",
  598. "new_value": "/",
  599. "expected": {
  600. "href": "sc:///",
  601. "host": "",
  602. "hostname": ""
  603. }
  604. },
  605. {
  606. "href": "sc://x/",
  607. "new_value": "?",
  608. "expected": {
  609. "href": "sc:///",
  610. "host": "",
  611. "hostname": ""
  612. }
  613. },
  614. {
  615. "href": "sc://x/",
  616. "new_value": "@",
  617. "expected": {
  618. "href": "sc://x/",
  619. "host": "x",
  620. "hostname": "x"
  621. }
  622. },
  623. {
  624. "href": "sc://x/",
  625. "new_value": "ß",
  626. "expected": {
  627. "href": "sc://%C3%9F/",
  628. "host": "%C3%9F",
  629. "hostname": "%C3%9F"
  630. }
  631. },
  632. {
  633. "comment": "IDNA Nontransitional_Processing",
  634. "href": "https://x/",
  635. "new_value": "ß",
  636. "expected": {
  637. "href": "https://xn--zca/",
  638. "host": "xn--zca",
  639. "hostname": "xn--zca"
  640. }
  641. },
  642. {
  643. "comment": "Cannot-be-a-base means no host",
  644. "href": "mailto:me@example.net",
  645. "new_value": "example.com",
  646. "expected": {
  647. "href": "mailto:me@example.net",
  648. "host": ""
  649. }
  650. },
  651. {
  652. "comment": "Cannot-be-a-base means no host",
  653. "href": "data:text/plain,Stuff",
  654. "new_value": "example.net",
  655. "expected": {
  656. "href": "data:text/plain,Stuff",
  657. "host": ""
  658. }
  659. },
  660. {
  661. "href": "http://example.net",
  662. "new_value": "example.com:8080",
  663. "expected": {
  664. "href": "http://example.com:8080/",
  665. "host": "example.com:8080",
  666. "hostname": "example.com",
  667. "port": "8080"
  668. }
  669. },
  670. {
  671. "comment": "Port number is unchanged if not specified in the new value",
  672. "href": "http://example.net:8080",
  673. "new_value": "example.com",
  674. "expected": {
  675. "href": "http://example.com:8080/",
  676. "host": "example.com:8080",
  677. "hostname": "example.com",
  678. "port": "8080"
  679. }
  680. },
  681. {
  682. "comment": "Port number is unchanged if not specified",
  683. "href": "http://example.net:8080",
  684. "new_value": "example.com:",
  685. "expected": {
  686. "href": "http://example.com:8080/",
  687. "host": "example.com:8080",
  688. "hostname": "example.com",
  689. "port": "8080"
  690. }
  691. },
  692. {
  693. "comment": "The empty host is not valid for special schemes",
  694. "href": "http://example.net",
  695. "new_value": "",
  696. "expected": {
  697. "href": "http://example.net/",
  698. "host": "example.net"
  699. }
  700. },
  701. {
  702. "comment": "The empty host is OK for non-special schemes",
  703. "href": "view-source+http://example.net/foo",
  704. "new_value": "",
  705. "expected": {
  706. "href": "view-source+http:///foo",
  707. "host": ""
  708. }
  709. },
  710. {
  711. "comment": "Path-only URLs can gain a host",
  712. "href": "a:/foo",
  713. "new_value": "example.net",
  714. "expected": {
  715. "href": "a://example.net/foo",
  716. "host": "example.net"
  717. }
  718. },
  719. {
  720. "comment": "IPv4 address syntax is normalized",
  721. "href": "http://example.net",
  722. "new_value": "0x7F000001:8080",
  723. "expected": {
  724. "href": "http://127.0.0.1:8080/",
  725. "host": "127.0.0.1:8080",
  726. "hostname": "127.0.0.1",
  727. "port": "8080"
  728. }
  729. },
  730. {
  731. "comment": "IPv6 address syntax is normalized",
  732. "href": "http://example.net",
  733. "new_value": "[::0:01]:2",
  734. "expected": {
  735. "href": "http://[::1]:2/",
  736. "host": "[::1]:2",
  737. "hostname": "[::1]",
  738. "port": "2"
  739. }
  740. },
  741. {
  742. "comment": "IPv6 literal address with port, crbug.com/1012416",
  743. "href": "http://example.net",
  744. "new_value": "[2001:db8::2]:4002",
  745. "expected": {
  746. "href": "http://[2001:db8::2]:4002/",
  747. "host": "[2001:db8::2]:4002",
  748. "hostname": "[2001:db8::2]",
  749. "port": "4002"
  750. }
  751. },
  752. {
  753. "comment": "Default port number is removed",
  754. "href": "http://example.net",
  755. "new_value": "example.com:80",
  756. "expected": {
  757. "href": "http://example.com/",
  758. "host": "example.com",
  759. "hostname": "example.com",
  760. "port": ""
  761. }
  762. },
  763. {
  764. "comment": "Default port number is removed",
  765. "href": "https://example.net",
  766. "new_value": "example.com:443",
  767. "expected": {
  768. "href": "https://example.com/",
  769. "host": "example.com",
  770. "hostname": "example.com",
  771. "port": ""
  772. }
  773. },
  774. {
  775. "comment": "Default port number is only removed for the relevant scheme",
  776. "href": "https://example.net",
  777. "new_value": "example.com:80",
  778. "expected": {
  779. "href": "https://example.com:80/",
  780. "host": "example.com:80",
  781. "hostname": "example.com",
  782. "port": "80"
  783. }
  784. },
  785. {
  786. "comment": "Port number is removed if new port is scheme default and existing URL has a non-default port",
  787. "href": "http://example.net:8080",
  788. "new_value": "example.com:80",
  789. "expected": {
  790. "href": "http://example.com/",
  791. "host": "example.com",
  792. "hostname": "example.com",
  793. "port": ""
  794. }
  795. },
  796. {
  797. "comment": "Stuff after a / delimiter is ignored",
  798. "href": "http://example.net/path",
  799. "new_value": "example.com/stuff",
  800. "expected": {
  801. "href": "http://example.com/path",
  802. "host": "example.com",
  803. "hostname": "example.com",
  804. "port": ""
  805. }
  806. },
  807. {
  808. "comment": "Stuff after a / delimiter is ignored",
  809. "href": "http://example.net/path",
  810. "new_value": "example.com:8080/stuff",
  811. "expected": {
  812. "href": "http://example.com:8080/path",
  813. "host": "example.com:8080",
  814. "hostname": "example.com",
  815. "port": "8080"
  816. }
  817. },
  818. {
  819. "comment": "Stuff after a ? delimiter is ignored",
  820. "href": "http://example.net/path",
  821. "new_value": "example.com?stuff",
  822. "expected": {
  823. "href": "http://example.com/path",
  824. "host": "example.com",
  825. "hostname": "example.com",
  826. "port": ""
  827. }
  828. },
  829. {
  830. "comment": "Stuff after a ? delimiter is ignored, trailing 'port'",
  831. "href": "http://example.net/path",
  832. "new_value": "example.com?stuff:8080",
  833. "expected": {
  834. "href": "http://example.com/path",
  835. "host": "example.com",
  836. "hostname": "example.com",
  837. "port": ""
  838. }
  839. },
  840. {
  841. "comment": "Stuff after a ? delimiter is ignored",
  842. "href": "http://example.net/path",
  843. "new_value": "example.com:8080?stuff",
  844. "expected": {
  845. "href": "http://example.com:8080/path",
  846. "host": "example.com:8080",
  847. "hostname": "example.com",
  848. "port": "8080"
  849. }
  850. },
  851. {
  852. "comment": "Stuff after a # delimiter is ignored",
  853. "href": "http://example.net/path",
  854. "new_value": "example.com#stuff",
  855. "expected": {
  856. "href": "http://example.com/path",
  857. "host": "example.com",
  858. "hostname": "example.com",
  859. "port": ""
  860. }
  861. },
  862. {
  863. "comment": "Stuff after a # delimiter is ignored",
  864. "href": "http://example.net/path",
  865. "new_value": "example.com:8080#stuff",
  866. "expected": {
  867. "href": "http://example.com:8080/path",
  868. "host": "example.com:8080",
  869. "hostname": "example.com",
  870. "port": "8080"
  871. }
  872. },
  873. {
  874. "comment": "Stuff after a \\ delimiter is ignored for special schemes",
  875. "href": "http://example.net/path",
  876. "new_value": "example.com\\stuff",
  877. "expected": {
  878. "href": "http://example.com/path",
  879. "host": "example.com",
  880. "hostname": "example.com",
  881. "port": ""
  882. }
  883. },
  884. {
  885. "comment": "Stuff after a \\ delimiter is ignored for special schemes",
  886. "href": "http://example.net/path",
  887. "new_value": "example.com:8080\\stuff",
  888. "expected": {
  889. "href": "http://example.com:8080/path",
  890. "host": "example.com:8080",
  891. "hostname": "example.com",
  892. "port": "8080"
  893. }
  894. },
  895. {
  896. "comment": "\\ is not a delimiter for non-special schemes, but still forbidden in hosts",
  897. "href": "view-source+http://example.net/path",
  898. "new_value": "example.com\\stuff",
  899. "expected": {
  900. "href": "view-source+http://example.net/path",
  901. "host": "example.net",
  902. "hostname": "example.net",
  903. "port": ""
  904. }
  905. },
  906. {
  907. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  908. "href": "view-source+http://example.net/path",
  909. "new_value": "example.com:8080stuff2",
  910. "expected": {
  911. "href": "view-source+http://example.com:8080/path",
  912. "host": "example.com:8080",
  913. "hostname": "example.com",
  914. "port": "8080"
  915. }
  916. },
  917. {
  918. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  919. "href": "http://example.net/path",
  920. "new_value": "example.com:8080stuff2",
  921. "expected": {
  922. "href": "http://example.com:8080/path",
  923. "host": "example.com:8080",
  924. "hostname": "example.com",
  925. "port": "8080"
  926. }
  927. },
  928. {
  929. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  930. "href": "http://example.net/path",
  931. "new_value": "example.com:8080+2",
  932. "expected": {
  933. "href": "http://example.com:8080/path",
  934. "host": "example.com:8080",
  935. "hostname": "example.com",
  936. "port": "8080"
  937. }
  938. },
  939. {
  940. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  941. "href": "http://example.net:8080",
  942. "new_value": "example.com:invalid",
  943. "expected": {
  944. "href": "http://example.com:8080/",
  945. "host": "example.com:8080",
  946. "hostname": "example.com",
  947. "port": "8080"
  948. }
  949. },
  950. {
  951. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  952. "href": "http://example.net:8080/test",
  953. "new_value": "[::1]:invalid",
  954. "expected": {
  955. "href": "http://[::1]:8080/test",
  956. "host": "[::1]:8080",
  957. "hostname": "[::1]",
  958. "port": "8080"
  959. }
  960. },
  961. {
  962. "comment": "IPv6 without port",
  963. "href": "http://example.net:8080/test",
  964. "new_value": "[::1]",
  965. "expected": {
  966. "href": "http://[::1]:8080/test",
  967. "host": "[::1]:8080",
  968. "hostname": "[::1]",
  969. "port": "8080"
  970. }
  971. },
  972. {
  973. "comment": "Port numbers are 16 bit integers",
  974. "href": "http://example.net/path",
  975. "new_value": "example.com:65535",
  976. "expected": {
  977. "href": "http://example.com:65535/path",
  978. "host": "example.com:65535",
  979. "hostname": "example.com",
  980. "port": "65535"
  981. }
  982. },
  983. {
  984. "comment": "Port numbers are 16 bit integers, overflowing is an error. Hostname is still set, though.",
  985. "href": "http://example.net/path",
  986. "new_value": "example.com:65536",
  987. "expected": {
  988. "href": "http://example.com/path",
  989. "host": "example.com",
  990. "hostname": "example.com",
  991. "port": ""
  992. }
  993. },
  994. {
  995. "comment": "Broken IPv6",
  996. "href": "http://example.net/",
  997. "new_value": "[google.com]",
  998. "expected": {
  999. "href": "http://example.net/",
  1000. "host": "example.net",
  1001. "hostname": "example.net"
  1002. }
  1003. },
  1004. {
  1005. "href": "http://example.net/",
  1006. "new_value": "[::1.2.3.4x]",
  1007. "expected": {
  1008. "href": "http://example.net/",
  1009. "host": "example.net",
  1010. "hostname": "example.net"
  1011. }
  1012. },
  1013. {
  1014. "href": "http://example.net/",
  1015. "new_value": "[::1.2.3.]",
  1016. "expected": {
  1017. "href": "http://example.net/",
  1018. "host": "example.net",
  1019. "hostname": "example.net"
  1020. }
  1021. },
  1022. {
  1023. "href": "http://example.net/",
  1024. "new_value": "[::1.2.]",
  1025. "expected": {
  1026. "href": "http://example.net/",
  1027. "host": "example.net",
  1028. "hostname": "example.net"
  1029. }
  1030. },
  1031. {
  1032. "href": "http://example.net/",
  1033. "new_value": "[::1.]",
  1034. "expected": {
  1035. "href": "http://example.net/",
  1036. "host": "example.net",
  1037. "hostname": "example.net"
  1038. }
  1039. },
  1040. {
  1041. "href": "file://y/",
  1042. "new_value": "x:123",
  1043. "expected": {
  1044. "href": "file://y/",
  1045. "host": "y",
  1046. "hostname": "y",
  1047. "port": ""
  1048. }
  1049. },
  1050. {
  1051. "href": "file://y/",
  1052. "new_value": "loc%41lhost",
  1053. "expected": {
  1054. "href": "file:///",
  1055. "host": "",
  1056. "hostname": "",
  1057. "port": ""
  1058. }
  1059. },
  1060. {
  1061. "href": "file://hi/x",
  1062. "new_value": "",
  1063. "expected": {
  1064. "href": "file:///x",
  1065. "host": "",
  1066. "hostname": "",
  1067. "port": ""
  1068. }
  1069. },
  1070. {
  1071. "href": "sc://test@test/",
  1072. "new_value": "",
  1073. "expected": {
  1074. "href": "sc://test@test/",
  1075. "host": "test",
  1076. "hostname": "test",
  1077. "username": "test"
  1078. }
  1079. },
  1080. {
  1081. "href": "sc://test:12/",
  1082. "new_value": "",
  1083. "expected": {
  1084. "href": "sc://test:12/",
  1085. "host": "test:12",
  1086. "hostname": "test",
  1087. "port": "12"
  1088. }
  1089. },
  1090. {
  1091. "comment": "Leading / is not stripped",
  1092. "href": "http://example.com/",
  1093. "new_value": "///bad.com",
  1094. "expected": {
  1095. "href": "http://example.com/",
  1096. "host": "example.com",
  1097. "hostname": "example.com"
  1098. }
  1099. },
  1100. {
  1101. "comment": "Leading / is not stripped",
  1102. "href": "sc://example.com/",
  1103. "new_value": "///bad.com",
  1104. "expected": {
  1105. "href": "sc:///",
  1106. "host": "",
  1107. "hostname": ""
  1108. }
  1109. },
  1110. {
  1111. "href": "https://example.com/",
  1112. "new_value": "a%C2%ADb",
  1113. "expected": {
  1114. "href": "https://ab/",
  1115. "host": "ab",
  1116. "hostname": "ab"
  1117. }
  1118. },
  1119. {
  1120. "href": "https://example.com/",
  1121. "new_value": "\u00AD",
  1122. "expected": {
  1123. "href": "https://example.com/",
  1124. "host": "example.com",
  1125. "hostname": "example.com"
  1126. }
  1127. },
  1128. {
  1129. "href": "https://example.com/",
  1130. "new_value": "%C2%AD",
  1131. "expected": {
  1132. "href": "https://example.com/",
  1133. "host": "example.com",
  1134. "hostname": "example.com"
  1135. }
  1136. },
  1137. {
  1138. "href": "https://example.com/",
  1139. "new_value": "xn--",
  1140. "expected": {
  1141. "href": "https://example.com/",
  1142. "host": "example.com",
  1143. "hostname": "example.com"
  1144. }
  1145. },
  1146. {
  1147. "href": "https://test.invalid/",
  1148. "new_value": "*",
  1149. "expected": {
  1150. "href": "https://*/",
  1151. "host": "*",
  1152. "hostname": "*"
  1153. }
  1154. },
  1155. {
  1156. "href": "https://test.invalid/",
  1157. "new_value": "x@x",
  1158. "expected": {
  1159. "href": "https://test.invalid/",
  1160. "host": "test.invalid",
  1161. "hostname": "test.invalid"
  1162. }
  1163. },
  1164. {
  1165. "href": "https://test.invalid/",
  1166. "new_value": "foo\t\r\nbar",
  1167. "expected": {
  1168. "href": "https://foobar/",
  1169. "host": "foobar",
  1170. "hostname": "foobar"
  1171. }
  1172. },
  1173. {
  1174. "href": "https://test.invalid/",
  1175. "new_value": "><",
  1176. "expected": {
  1177. "href": "https://test.invalid/",
  1178. "host": "test.invalid",
  1179. "hostname": "test.invalid"
  1180. }
  1181. },
  1182. {
  1183. "href": "https://test.invalid/",
  1184. "new_value": "test/@aaa",
  1185. "expected": {
  1186. "href": "https://test/",
  1187. "host": "test",
  1188. "hostname": "test"
  1189. }
  1190. },
  1191. {
  1192. "href": "https://test.invalid/",
  1193. "new_value": "test/:aaa",
  1194. "expected": {
  1195. "href": "https://test/",
  1196. "host": "test",
  1197. "hostname": "test"
  1198. }
  1199. },
  1200. {
  1201. "href": "foo://path/to",
  1202. "new_value": ":80",
  1203. "expected": {
  1204. "href": "foo://path/to",
  1205. "host": "path",
  1206. "port": ""
  1207. }
  1208. }
  1209. ],
  1210. "hostname": [
  1211. {
  1212. "comment": "Non-special scheme",
  1213. "href": "sc://x/",
  1214. "new_value": "\u0000",
  1215. "expected": {
  1216. "href": "sc://x/",
  1217. "host": "x",
  1218. "hostname": "x"
  1219. }
  1220. },
  1221. {
  1222. "href": "sc://x/",
  1223. "new_value": "\u0009",
  1224. "expected": {
  1225. "href": "sc:///",
  1226. "host": "",
  1227. "hostname": ""
  1228. }
  1229. },
  1230. {
  1231. "href": "sc://x/",
  1232. "new_value": "\u000A",
  1233. "expected": {
  1234. "href": "sc:///",
  1235. "host": "",
  1236. "hostname": ""
  1237. }
  1238. },
  1239. {
  1240. "href": "sc://x/",
  1241. "new_value": "\u000D",
  1242. "expected": {
  1243. "href": "sc:///",
  1244. "host": "",
  1245. "hostname": ""
  1246. }
  1247. },
  1248. {
  1249. "href": "sc://x/",
  1250. "new_value": " ",
  1251. "expected": {
  1252. "href": "sc://x/",
  1253. "host": "x",
  1254. "hostname": "x"
  1255. }
  1256. },
  1257. {
  1258. "href": "sc://x/",
  1259. "new_value": "#",
  1260. "expected": {
  1261. "href": "sc:///",
  1262. "host": "",
  1263. "hostname": ""
  1264. }
  1265. },
  1266. {
  1267. "href": "sc://x/",
  1268. "new_value": "/",
  1269. "expected": {
  1270. "href": "sc:///",
  1271. "host": "",
  1272. "hostname": ""
  1273. }
  1274. },
  1275. {
  1276. "href": "sc://x/",
  1277. "new_value": "?",
  1278. "expected": {
  1279. "href": "sc:///",
  1280. "host": "",
  1281. "hostname": ""
  1282. }
  1283. },
  1284. {
  1285. "href": "sc://x/",
  1286. "new_value": "@",
  1287. "expected": {
  1288. "href": "sc://x/",
  1289. "host": "x",
  1290. "hostname": "x"
  1291. }
  1292. },
  1293. {
  1294. "comment": "Cannot-be-a-base means no host",
  1295. "href": "mailto:me@example.net",
  1296. "new_value": "example.com",
  1297. "expected": {
  1298. "href": "mailto:me@example.net",
  1299. "host": ""
  1300. }
  1301. },
  1302. {
  1303. "comment": "Cannot-be-a-base means no host",
  1304. "href": "data:text/plain,Stuff",
  1305. "new_value": "example.net",
  1306. "expected": {
  1307. "href": "data:text/plain,Stuff",
  1308. "host": ""
  1309. }
  1310. },
  1311. {
  1312. "href": "http://example.net:8080",
  1313. "new_value": "example.com",
  1314. "expected": {
  1315. "href": "http://example.com:8080/",
  1316. "host": "example.com:8080",
  1317. "hostname": "example.com",
  1318. "port": "8080"
  1319. }
  1320. },
  1321. {
  1322. "comment": "The empty host is not valid for special schemes",
  1323. "href": "http://example.net",
  1324. "new_value": "",
  1325. "expected": {
  1326. "href": "http://example.net/",
  1327. "host": "example.net"
  1328. }
  1329. },
  1330. {
  1331. "comment": "The empty host is OK for non-special schemes",
  1332. "href": "view-source+http://example.net/foo",
  1333. "new_value": "",
  1334. "expected": {
  1335. "href": "view-source+http:///foo",
  1336. "host": ""
  1337. }
  1338. },
  1339. {
  1340. "comment": "Path-only URLs can gain a host",
  1341. "href": "a:/foo",
  1342. "new_value": "example.net",
  1343. "expected": {
  1344. "href": "a://example.net/foo",
  1345. "host": "example.net"
  1346. }
  1347. },
  1348. {
  1349. "comment": "IPv4 address syntax is normalized",
  1350. "href": "http://example.net:8080",
  1351. "new_value": "0x7F000001",
  1352. "expected": {
  1353. "href": "http://127.0.0.1:8080/",
  1354. "host": "127.0.0.1:8080",
  1355. "hostname": "127.0.0.1",
  1356. "port": "8080"
  1357. }
  1358. },
  1359. {
  1360. "comment": "IPv6 address syntax is normalized",
  1361. "href": "http://example.net",
  1362. "new_value": "[::0:01]",
  1363. "expected": {
  1364. "href": "http://[::1]/",
  1365. "host": "[::1]",
  1366. "hostname": "[::1]",
  1367. "port": ""
  1368. }
  1369. },
  1370. {
  1371. "comment": ": delimiter invalidates entire value",
  1372. "href": "http://example.net/path",
  1373. "new_value": "example.com:8080",
  1374. "expected": {
  1375. "href": "http://example.net/path",
  1376. "host": "example.net",
  1377. "hostname": "example.net",
  1378. "port": ""
  1379. }
  1380. },
  1381. {
  1382. "comment": ": delimiter invalidates entire value",
  1383. "href": "http://example.net:8080/path",
  1384. "new_value": "example.com:",
  1385. "expected": {
  1386. "href": "http://example.net:8080/path",
  1387. "host": "example.net:8080",
  1388. "hostname": "example.net",
  1389. "port": "8080"
  1390. }
  1391. },
  1392. {
  1393. "comment": "Stuff after a / delimiter is ignored",
  1394. "href": "http://example.net/path",
  1395. "new_value": "example.com/stuff",
  1396. "expected": {
  1397. "href": "http://example.com/path",
  1398. "host": "example.com",
  1399. "hostname": "example.com",
  1400. "port": ""
  1401. }
  1402. },
  1403. {
  1404. "comment": "Stuff after a ? delimiter is ignored",
  1405. "href": "http://example.net/path",
  1406. "new_value": "example.com?stuff",
  1407. "expected": {
  1408. "href": "http://example.com/path",
  1409. "host": "example.com",
  1410. "hostname": "example.com",
  1411. "port": ""
  1412. }
  1413. },
  1414. {
  1415. "comment": "Stuff after a # delimiter is ignored",
  1416. "href": "http://example.net/path",
  1417. "new_value": "example.com#stuff",
  1418. "expected": {
  1419. "href": "http://example.com/path",
  1420. "host": "example.com",
  1421. "hostname": "example.com",
  1422. "port": ""
  1423. }
  1424. },
  1425. {
  1426. "comment": "Stuff after a \\ delimiter is ignored for special schemes",
  1427. "href": "http://example.net/path",
  1428. "new_value": "example.com\\stuff",
  1429. "expected": {
  1430. "href": "http://example.com/path",
  1431. "host": "example.com",
  1432. "hostname": "example.com",
  1433. "port": ""
  1434. }
  1435. },
  1436. {
  1437. "comment": "\\ is not a delimiter for non-special schemes, but still forbidden in hosts",
  1438. "href": "view-source+http://example.net/path",
  1439. "new_value": "example.com\\stuff",
  1440. "expected": {
  1441. "href": "view-source+http://example.net/path",
  1442. "host": "example.net",
  1443. "hostname": "example.net",
  1444. "port": ""
  1445. }
  1446. },
  1447. {
  1448. "comment": "Broken IPv6",
  1449. "href": "http://example.net/",
  1450. "new_value": "[google.com]",
  1451. "expected": {
  1452. "href": "http://example.net/",
  1453. "host": "example.net",
  1454. "hostname": "example.net"
  1455. }
  1456. },
  1457. {
  1458. "href": "http://example.net/",
  1459. "new_value": "[::1.2.3.4x]",
  1460. "expected": {
  1461. "href": "http://example.net/",
  1462. "host": "example.net",
  1463. "hostname": "example.net"
  1464. }
  1465. },
  1466. {
  1467. "href": "http://example.net/",
  1468. "new_value": "[::1.2.3.]",
  1469. "expected": {
  1470. "href": "http://example.net/",
  1471. "host": "example.net",
  1472. "hostname": "example.net"
  1473. }
  1474. },
  1475. {
  1476. "href": "http://example.net/",
  1477. "new_value": "[::1.2.]",
  1478. "expected": {
  1479. "href": "http://example.net/",
  1480. "host": "example.net",
  1481. "hostname": "example.net"
  1482. }
  1483. },
  1484. {
  1485. "href": "http://example.net/",
  1486. "new_value": "[::1.]",
  1487. "expected": {
  1488. "href": "http://example.net/",
  1489. "host": "example.net",
  1490. "hostname": "example.net"
  1491. }
  1492. },
  1493. {
  1494. "href": "file://y/",
  1495. "new_value": "x:123",
  1496. "expected": {
  1497. "href": "file://y/",
  1498. "host": "y",
  1499. "hostname": "y",
  1500. "port": ""
  1501. }
  1502. },
  1503. {
  1504. "href": "file://y/",
  1505. "new_value": "loc%41lhost",
  1506. "expected": {
  1507. "href": "file:///",
  1508. "host": "",
  1509. "hostname": "",
  1510. "port": ""
  1511. }
  1512. },
  1513. {
  1514. "href": "file://hi/x",
  1515. "new_value": "",
  1516. "expected": {
  1517. "href": "file:///x",
  1518. "host": "",
  1519. "hostname": "",
  1520. "port": ""
  1521. }
  1522. },
  1523. {
  1524. "href": "sc://test@test/",
  1525. "new_value": "",
  1526. "expected": {
  1527. "href": "sc://test@test/",
  1528. "host": "test",
  1529. "hostname": "test",
  1530. "username": "test"
  1531. }
  1532. },
  1533. {
  1534. "href": "sc://test:12/",
  1535. "new_value": "",
  1536. "expected": {
  1537. "href": "sc://test:12/",
  1538. "host": "test:12",
  1539. "hostname": "test",
  1540. "port": "12"
  1541. }
  1542. },
  1543. {
  1544. "comment": "Drop /. from path",
  1545. "href": "non-spec:/.//p",
  1546. "new_value": "h",
  1547. "expected": {
  1548. "href": "non-spec://h//p",
  1549. "host": "h",
  1550. "hostname": "h",
  1551. "pathname": "//p"
  1552. }
  1553. },
  1554. {
  1555. "href": "non-spec:/.//p",
  1556. "new_value": "",
  1557. "expected": {
  1558. "href": "non-spec:////p",
  1559. "host": "",
  1560. "hostname": "",
  1561. "pathname": "//p"
  1562. }
  1563. },
  1564. {
  1565. "comment": "Leading / is not stripped",
  1566. "href": "http://example.com/",
  1567. "new_value": "///bad.com",
  1568. "expected": {
  1569. "href": "http://example.com/",
  1570. "host": "example.com",
  1571. "hostname": "example.com"
  1572. }
  1573. },
  1574. {
  1575. "comment": "Leading / is not stripped",
  1576. "href": "sc://example.com/",
  1577. "new_value": "///bad.com",
  1578. "expected": {
  1579. "href": "sc:///",
  1580. "host": "",
  1581. "hostname": ""
  1582. }
  1583. },
  1584. {
  1585. "href": "https://example.com/",
  1586. "new_value": "a%C2%ADb",
  1587. "expected": {
  1588. "href": "https://ab/",
  1589. "host": "ab",
  1590. "hostname": "ab"
  1591. }
  1592. },
  1593. {
  1594. "href": "https://example.com/",
  1595. "new_value": "\u00AD",
  1596. "expected": {
  1597. "href": "https://example.com/",
  1598. "host": "example.com",
  1599. "hostname": "example.com"
  1600. }
  1601. },
  1602. {
  1603. "href": "https://example.com/",
  1604. "new_value": "%C2%AD",
  1605. "expected": {
  1606. "href": "https://example.com/",
  1607. "host": "example.com",
  1608. "hostname": "example.com"
  1609. }
  1610. },
  1611. {
  1612. "href": "https://example.com/",
  1613. "new_value": "xn--",
  1614. "expected": {
  1615. "href": "https://example.com/",
  1616. "host": "example.com",
  1617. "hostname": "example.com"
  1618. }
  1619. },
  1620. {
  1621. "href": "https://test.invalid/",
  1622. "new_value": "*",
  1623. "expected": {
  1624. "href": "https://*/",
  1625. "host": "*",
  1626. "hostname": "*"
  1627. }
  1628. },
  1629. {
  1630. "href": "https://test.invalid/",
  1631. "new_value": "x@x",
  1632. "expected": {
  1633. "href": "https://test.invalid/",
  1634. "host": "test.invalid",
  1635. "hostname": "test.invalid"
  1636. }
  1637. },
  1638. {
  1639. "href": "https://test.invalid/",
  1640. "new_value": "foo\t\r\nbar",
  1641. "expected": {
  1642. "href": "https://foobar/",
  1643. "host": "foobar",
  1644. "hostname": "foobar"
  1645. }
  1646. },
  1647. {
  1648. "href": "https://test.invalid/",
  1649. "new_value": "><",
  1650. "expected": {
  1651. "href": "https://test.invalid/",
  1652. "host": "test.invalid",
  1653. "hostname": "test.invalid"
  1654. }
  1655. },
  1656. {
  1657. "href": "https://test.invalid/",
  1658. "new_value": "test/@aaa",
  1659. "expected": {
  1660. "href": "https://test/",
  1661. "host": "test",
  1662. "hostname": "test"
  1663. }
  1664. },
  1665. {
  1666. "href": "https://test.invalid/",
  1667. "new_value": "test/:aaa",
  1668. "expected": {
  1669. "href": "https://test/",
  1670. "host": "test",
  1671. "hostname": "test"
  1672. }
  1673. }
  1674. ],
  1675. "port": [
  1676. {
  1677. "href": "http://example.net",
  1678. "new_value": "8080",
  1679. "expected": {
  1680. "href": "http://example.net:8080/",
  1681. "host": "example.net:8080",
  1682. "hostname": "example.net",
  1683. "port": "8080"
  1684. }
  1685. },
  1686. {
  1687. "comment": "Port number is removed if empty is the new value",
  1688. "href": "http://example.net:8080",
  1689. "new_value": "",
  1690. "expected": {
  1691. "href": "http://example.net/",
  1692. "host": "example.net",
  1693. "hostname": "example.net",
  1694. "port": ""
  1695. }
  1696. },
  1697. {
  1698. "comment": "Default port number is removed",
  1699. "href": "http://example.net:8080",
  1700. "new_value": "80",
  1701. "expected": {
  1702. "href": "http://example.net/",
  1703. "host": "example.net",
  1704. "hostname": "example.net",
  1705. "port": ""
  1706. }
  1707. },
  1708. {
  1709. "comment": "Default port number is removed",
  1710. "href": "https://example.net:4433",
  1711. "new_value": "443",
  1712. "expected": {
  1713. "href": "https://example.net/",
  1714. "host": "example.net",
  1715. "hostname": "example.net",
  1716. "port": ""
  1717. }
  1718. },
  1719. {
  1720. "comment": "Default port number is only removed for the relevant scheme",
  1721. "href": "https://example.net",
  1722. "new_value": "80",
  1723. "expected": {
  1724. "href": "https://example.net:80/",
  1725. "host": "example.net:80",
  1726. "hostname": "example.net",
  1727. "port": "80"
  1728. }
  1729. },
  1730. {
  1731. "comment": "Stuff after a / delimiter is ignored",
  1732. "href": "http://example.net/path",
  1733. "new_value": "8080/stuff",
  1734. "expected": {
  1735. "href": "http://example.net:8080/path",
  1736. "host": "example.net:8080",
  1737. "hostname": "example.net",
  1738. "port": "8080"
  1739. }
  1740. },
  1741. {
  1742. "comment": "Stuff after a ? delimiter is ignored",
  1743. "href": "http://example.net/path",
  1744. "new_value": "8080?stuff",
  1745. "expected": {
  1746. "href": "http://example.net:8080/path",
  1747. "host": "example.net:8080",
  1748. "hostname": "example.net",
  1749. "port": "8080"
  1750. }
  1751. },
  1752. {
  1753. "comment": "Stuff after a # delimiter is ignored",
  1754. "href": "http://example.net/path",
  1755. "new_value": "8080#stuff",
  1756. "expected": {
  1757. "href": "http://example.net:8080/path",
  1758. "host": "example.net:8080",
  1759. "hostname": "example.net",
  1760. "port": "8080"
  1761. }
  1762. },
  1763. {
  1764. "comment": "Stuff after a \\ delimiter is ignored for special schemes",
  1765. "href": "http://example.net/path",
  1766. "new_value": "8080\\stuff",
  1767. "expected": {
  1768. "href": "http://example.net:8080/path",
  1769. "host": "example.net:8080",
  1770. "hostname": "example.net",
  1771. "port": "8080"
  1772. }
  1773. },
  1774. {
  1775. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  1776. "href": "view-source+http://example.net/path",
  1777. "new_value": "8080stuff2",
  1778. "expected": {
  1779. "href": "view-source+http://example.net:8080/path",
  1780. "host": "example.net:8080",
  1781. "hostname": "example.net",
  1782. "port": "8080"
  1783. }
  1784. },
  1785. {
  1786. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  1787. "href": "http://example.net/path",
  1788. "new_value": "8080stuff2",
  1789. "expected": {
  1790. "href": "http://example.net:8080/path",
  1791. "host": "example.net:8080",
  1792. "hostname": "example.net",
  1793. "port": "8080"
  1794. }
  1795. },
  1796. {
  1797. "comment": "Anything other than ASCII digit stops the port parser in a setter but is not an error",
  1798. "href": "http://example.net/path",
  1799. "new_value": "8080+2",
  1800. "expected": {
  1801. "href": "http://example.net:8080/path",
  1802. "host": "example.net:8080",
  1803. "hostname": "example.net",
  1804. "port": "8080"
  1805. }
  1806. },
  1807. {
  1808. "comment": "Port numbers are 16 bit integers",
  1809. "href": "http://example.net/path",
  1810. "new_value": "65535",
  1811. "expected": {
  1812. "href": "http://example.net:65535/path",
  1813. "host": "example.net:65535",
  1814. "hostname": "example.net",
  1815. "port": "65535"
  1816. }
  1817. },
  1818. {
  1819. "comment": "Port numbers are 16 bit integers, overflowing is an error",
  1820. "href": "http://example.net:8080/path",
  1821. "new_value": "65536",
  1822. "expected": {
  1823. "href": "http://example.net:8080/path",
  1824. "host": "example.net:8080",
  1825. "hostname": "example.net",
  1826. "port": "8080"
  1827. }
  1828. },
  1829. {
  1830. "comment": "Setting port to a string that doesn't parse as a number",
  1831. "href": "http://example.net:8080/path",
  1832. "new_value": "randomstring",
  1833. "expected": {
  1834. "href": "http://example.net:8080/path",
  1835. "host": "example.net:8080",
  1836. "hostname": "example.net",
  1837. "port": "8080"
  1838. }
  1839. },
  1840. {
  1841. "comment": "Port numbers are 16 bit integers, overflowing is an error",
  1842. "href": "non-special://example.net:8080/path",
  1843. "new_value": "65536",
  1844. "expected": {
  1845. "href": "non-special://example.net:8080/path",
  1846. "host": "example.net:8080",
  1847. "hostname": "example.net",
  1848. "port": "8080"
  1849. }
  1850. },
  1851. {
  1852. "href": "file://test/",
  1853. "new_value": "12",
  1854. "expected": {
  1855. "href": "file://test/",
  1856. "port": ""
  1857. }
  1858. },
  1859. {
  1860. "href": "file://localhost/",
  1861. "new_value": "12",
  1862. "expected": {
  1863. "href": "file:///",
  1864. "port": ""
  1865. }
  1866. },
  1867. {
  1868. "href": "non-base:value",
  1869. "new_value": "12",
  1870. "expected": {
  1871. "href": "non-base:value",
  1872. "port": ""
  1873. }
  1874. },
  1875. {
  1876. "href": "sc:///",
  1877. "new_value": "12",
  1878. "expected": {
  1879. "href": "sc:///",
  1880. "port": ""
  1881. }
  1882. },
  1883. {
  1884. "href": "sc://x/",
  1885. "new_value": "12",
  1886. "expected": {
  1887. "href": "sc://x:12/",
  1888. "port": "12"
  1889. }
  1890. },
  1891. {
  1892. "href": "javascript://x/",
  1893. "new_value": "12",
  1894. "expected": {
  1895. "href": "javascript://x:12/",
  1896. "port": "12"
  1897. }
  1898. },
  1899. {
  1900. "comment": "Leading u0009 on special scheme",
  1901. "href": "https://domain.com:443",
  1902. "new_value": "\u00098080",
  1903. "expected": {
  1904. "port": "8080"
  1905. }
  1906. },
  1907. {
  1908. "comment": "Leading u0009 on non-special scheme",
  1909. "href": "wpt++://domain.com:443",
  1910. "new_value": "\u00098080",
  1911. "expected": {
  1912. "port": "8080"
  1913. }
  1914. },
  1915. {
  1916. "comment": "Should use all ascii prefixed characters as port",
  1917. "href": "https://www.google.com:4343",
  1918. "new_value": "4wpt",
  1919. "expected": {
  1920. "port": "4"
  1921. }
  1922. },
  1923. {
  1924. "href": "https://domain.com:3000",
  1925. "new_value": "\n\t80\n\t80\n\t",
  1926. "expected": {
  1927. "port": "8080"
  1928. }
  1929. },
  1930. {
  1931. "href": "https://domain.com:3000",
  1932. "new_value": "\n\n\t\t",
  1933. "expected": {
  1934. "port": "3000"
  1935. }
  1936. }
  1937. ],
  1938. "pathname": [
  1939. {
  1940. "comment": "Opaque paths cannot be set",
  1941. "href": "mailto:me@example.net",
  1942. "new_value": "/foo",
  1943. "expected": {
  1944. "href": "mailto:me@example.net",
  1945. "pathname": "me@example.net"
  1946. }
  1947. },
  1948. {
  1949. "href": "data:original",
  1950. "new_value": "new value",
  1951. "expected": {
  1952. "href": "data:original",
  1953. "pathname": "original"
  1954. }
  1955. },
  1956. {
  1957. "href": "sc:original",
  1958. "new_value": "new value",
  1959. "expected": {
  1960. "href": "sc:original",
  1961. "pathname": "original"
  1962. }
  1963. },
  1964. {
  1965. "comment": "Special URLs cannot have their paths erased",
  1966. "href": "file:///some/path",
  1967. "new_value": "",
  1968. "expected": {
  1969. "href": "file:///",
  1970. "pathname": "/"
  1971. }
  1972. },
  1973. {
  1974. "comment": "Non-special URLs can have their paths erased",
  1975. "href": "foo://somehost/some/path",
  1976. "new_value": "",
  1977. "expected": {
  1978. "href": "foo://somehost",
  1979. "pathname": ""
  1980. }
  1981. },
  1982. {
  1983. "comment": "Non-special URLs with an empty host can have their paths erased",
  1984. "href": "foo:///some/path",
  1985. "new_value": "",
  1986. "expected": {
  1987. "href": "foo://",
  1988. "pathname": ""
  1989. }
  1990. },
  1991. {
  1992. "comment": "Path-only URLs cannot have their paths erased",
  1993. "href": "foo:/some/path",
  1994. "new_value": "",
  1995. "expected": {
  1996. "href": "foo:/",
  1997. "pathname": "/"
  1998. }
  1999. },
  2000. {
  2001. "comment": "Path-only URLs always have an initial slash",
  2002. "href": "foo:/some/path",
  2003. "new_value": "test",
  2004. "expected": {
  2005. "href": "foo:/test",
  2006. "pathname": "/test"
  2007. }
  2008. },
  2009. {
  2010. "href": "unix:/run/foo.socket?timeout=10",
  2011. "new_value": "/var/log/../run/bar.socket",
  2012. "expected": {
  2013. "href": "unix:/var/run/bar.socket?timeout=10",
  2014. "pathname": "/var/run/bar.socket"
  2015. }
  2016. },
  2017. {
  2018. "href": "https://example.net#nav",
  2019. "new_value": "home",
  2020. "expected": {
  2021. "href": "https://example.net/home#nav",
  2022. "pathname": "/home"
  2023. }
  2024. },
  2025. {
  2026. "href": "https://example.net#nav",
  2027. "new_value": "../home",
  2028. "expected": {
  2029. "href": "https://example.net/home#nav",
  2030. "pathname": "/home"
  2031. }
  2032. },
  2033. {
  2034. "comment": "\\ is a segment delimiter for 'special' URLs",
  2035. "href": "http://example.net/home?lang=fr#nav",
  2036. "new_value": "\\a\\%2E\\b\\%2e.\\c",
  2037. "expected": {
  2038. "href": "http://example.net/a/c?lang=fr#nav",
  2039. "pathname": "/a/c"
  2040. }
  2041. },
  2042. {
  2043. "comment": "\\ is *not* a segment delimiter for non-'special' URLs",
  2044. "href": "view-source+http://example.net/home?lang=fr#nav",
  2045. "new_value": "\\a\\%2E\\b\\%2e.\\c",
  2046. "expected": {
  2047. "href": "view-source+http://example.net/\\a\\%2E\\b\\%2e.\\c?lang=fr#nav",
  2048. "pathname": "/\\a\\%2E\\b\\%2e.\\c"
  2049. }
  2050. },
  2051. {
  2052. "comment": "UTF-8 percent encoding with the default encode set. Tabs and newlines are removed.",
  2053. "href": "a:/",
  2054. "new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
  2055. "expected": {
  2056. "href": "a:/%00%01%1F%20!%22%23$%&'()*+,-./09:;%3C=%3E%3F@AZ[\\]%5E_%60az%7B|%7D~%7F%C2%80%C2%81%C3%89%C3%A9",
  2057. "pathname": "/%00%01%1F%20!%22%23$%&'()*+,-./09:;%3C=%3E%3F@AZ[\\]%5E_%60az%7B|%7D~%7F%C2%80%C2%81%C3%89%C3%A9"
  2058. }
  2059. },
  2060. {
  2061. "comment": "Bytes already percent-encoded are left as-is, including %2E outside dotted segments.",
  2062. "href": "http://example.net",
  2063. "new_value": "%2e%2E%c3%89té",
  2064. "expected": {
  2065. "href": "http://example.net/%2e%2E%c3%89t%C3%A9",
  2066. "pathname": "/%2e%2E%c3%89t%C3%A9"
  2067. }
  2068. },
  2069. {
  2070. "comment": "? needs to be encoded",
  2071. "href": "http://example.net",
  2072. "new_value": "?",
  2073. "expected": {
  2074. "href": "http://example.net/%3F",
  2075. "pathname": "/%3F"
  2076. }
  2077. },
  2078. {
  2079. "comment": "# needs to be encoded",
  2080. "href": "http://example.net",
  2081. "new_value": "#",
  2082. "expected": {
  2083. "href": "http://example.net/%23",
  2084. "pathname": "/%23"
  2085. }
  2086. },
  2087. {
  2088. "comment": "? needs to be encoded, non-special scheme",
  2089. "href": "sc://example.net",
  2090. "new_value": "?",
  2091. "expected": {
  2092. "href": "sc://example.net/%3F",
  2093. "pathname": "/%3F"
  2094. }
  2095. },
  2096. {
  2097. "comment": "# needs to be encoded, non-special scheme",
  2098. "href": "sc://example.net",
  2099. "new_value": "#",
  2100. "expected": {
  2101. "href": "sc://example.net/%23",
  2102. "pathname": "/%23"
  2103. }
  2104. },
  2105. {
  2106. "comment": "? doesn't mess up encoding",
  2107. "href": "http://example.net",
  2108. "new_value": "/?é",
  2109. "expected": {
  2110. "href": "http://example.net/%3F%C3%A9",
  2111. "pathname": "/%3F%C3%A9"
  2112. }
  2113. },
  2114. {
  2115. "comment": "# doesn't mess up encoding",
  2116. "href": "http://example.net",
  2117. "new_value": "/#é",
  2118. "expected": {
  2119. "href": "http://example.net/%23%C3%A9",
  2120. "pathname": "/%23%C3%A9"
  2121. }
  2122. },
  2123. {
  2124. "comment": "File URLs and (back)slashes",
  2125. "href": "file://monkey/",
  2126. "new_value": "\\\\",
  2127. "expected": {
  2128. "href": "file://monkey//",
  2129. "pathname": "//"
  2130. }
  2131. },
  2132. {
  2133. "comment": "File URLs and (back)slashes",
  2134. "href": "file:///unicorn",
  2135. "new_value": "//\\/",
  2136. "expected": {
  2137. "href": "file://////",
  2138. "pathname": "////"
  2139. }
  2140. },
  2141. {
  2142. "comment": "File URLs and (back)slashes",
  2143. "href": "file:///unicorn",
  2144. "new_value": "//monkey/..//",
  2145. "expected": {
  2146. "href": "file://///",
  2147. "pathname": "///"
  2148. }
  2149. },
  2150. {
  2151. "comment": "Serialize /. in path",
  2152. "href": "non-spec:/",
  2153. "new_value": "/.//p",
  2154. "expected": {
  2155. "href": "non-spec:/.//p",
  2156. "pathname": "//p"
  2157. }
  2158. },
  2159. {
  2160. "href": "non-spec:/",
  2161. "new_value": "/..//p",
  2162. "expected": {
  2163. "href": "non-spec:/.//p",
  2164. "pathname": "//p"
  2165. }
  2166. },
  2167. {
  2168. "href": "non-spec:/",
  2169. "new_value": "//p",
  2170. "expected": {
  2171. "href": "non-spec:/.//p",
  2172. "pathname": "//p"
  2173. }
  2174. },
  2175. {
  2176. "comment": "Drop /. from path",
  2177. "href": "non-spec:/.//",
  2178. "new_value": "p",
  2179. "expected": {
  2180. "href": "non-spec:/p",
  2181. "pathname": "/p"
  2182. }
  2183. },
  2184. {
  2185. "comment": "Non-special URLs with non-opaque paths percent-encode U+0020",
  2186. "href": "data:/nospace",
  2187. "new_value": "space ",
  2188. "expected": {
  2189. "href": "data:/space%20",
  2190. "pathname": "/space%20"
  2191. }
  2192. },
  2193. {
  2194. "href": "sc:/nospace",
  2195. "new_value": "space ",
  2196. "expected": {
  2197. "href": "sc:/space%20",
  2198. "pathname": "/space%20"
  2199. }
  2200. },
  2201. {
  2202. "comment": "Trailing space should be encoded",
  2203. "href": "http://example.net",
  2204. "new_value": " ",
  2205. "expected": {
  2206. "href": "http://example.net/%20",
  2207. "pathname": "/%20"
  2208. }
  2209. },
  2210. {
  2211. "comment": "Trailing C0 control should be encoded",
  2212. "href": "http://example.net",
  2213. "new_value": "\u0000",
  2214. "expected": {
  2215. "href": "http://example.net/%00",
  2216. "pathname": "/%00"
  2217. }
  2218. },
  2219. {
  2220. "href": "foo://path/to",
  2221. "new_value": "/..",
  2222. "expected": {
  2223. "href": "foo://path/",
  2224. "pathname": "/"
  2225. }
  2226. }
  2227. ],
  2228. "search": [
  2229. {
  2230. "href": "https://example.net#nav",
  2231. "new_value": "lang=fr",
  2232. "expected": {
  2233. "href": "https://example.net/?lang=fr#nav",
  2234. "search": "?lang=fr"
  2235. }
  2236. },
  2237. {
  2238. "href": "https://example.net?lang=en-US#nav",
  2239. "new_value": "lang=fr",
  2240. "expected": {
  2241. "href": "https://example.net/?lang=fr#nav",
  2242. "search": "?lang=fr"
  2243. }
  2244. },
  2245. {
  2246. "href": "https://example.net?lang=en-US#nav",
  2247. "new_value": "?lang=fr",
  2248. "expected": {
  2249. "href": "https://example.net/?lang=fr#nav",
  2250. "search": "?lang=fr"
  2251. }
  2252. },
  2253. {
  2254. "href": "https://example.net?lang=en-US#nav",
  2255. "new_value": "??lang=fr",
  2256. "expected": {
  2257. "href": "https://example.net/??lang=fr#nav",
  2258. "search": "??lang=fr"
  2259. }
  2260. },
  2261. {
  2262. "href": "https://example.net?lang=en-US#nav",
  2263. "new_value": "?",
  2264. "expected": {
  2265. "href": "https://example.net/?#nav",
  2266. "search": ""
  2267. }
  2268. },
  2269. {
  2270. "href": "https://example.net?lang=en-US#nav",
  2271. "new_value": "",
  2272. "expected": {
  2273. "href": "https://example.net/#nav",
  2274. "search": ""
  2275. }
  2276. },
  2277. {
  2278. "href": "https://example.net?lang=en-US",
  2279. "new_value": "",
  2280. "expected": {
  2281. "href": "https://example.net/",
  2282. "search": ""
  2283. }
  2284. },
  2285. {
  2286. "href": "https://example.net",
  2287. "new_value": "",
  2288. "expected": {
  2289. "href": "https://example.net/",
  2290. "search": ""
  2291. }
  2292. },
  2293. {
  2294. "comment": "UTF-8 percent encoding with the query encode set. Tabs and newlines are removed.",
  2295. "href": "a:/",
  2296. "new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
  2297. "expected": {
  2298. "href": "a:/?%00%01%1F%20!%22%23$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_`az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
  2299. "search": "?%00%01%1F%20!%22%23$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_`az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
  2300. }
  2301. },
  2302. {
  2303. "comment": "Bytes already percent-encoded are left as-is",
  2304. "href": "http://example.net",
  2305. "new_value": "%c3%89té",
  2306. "expected": {
  2307. "href": "http://example.net/?%c3%89t%C3%A9",
  2308. "search": "?%c3%89t%C3%A9"
  2309. }
  2310. },
  2311. {
  2312. "comment": "Trailing spaces and opaque paths",
  2313. "href": "data:space ?query",
  2314. "new_value": "",
  2315. "expected": {
  2316. "href": "data:space%20",
  2317. "pathname": "space%20",
  2318. "search": ""
  2319. }
  2320. },
  2321. {
  2322. "href": "sc:space ?query",
  2323. "new_value": "",
  2324. "expected": {
  2325. "href": "sc:space%20",
  2326. "pathname": "space%20",
  2327. "search": ""
  2328. }
  2329. },
  2330. {
  2331. "comment": "Trailing spaces and opaque paths",
  2332. "href": "data:space ?query#fragment",
  2333. "new_value": "",
  2334. "expected": {
  2335. "href": "data:space %20#fragment",
  2336. "search": ""
  2337. }
  2338. },
  2339. {
  2340. "href": "sc:space ?query#fragment",
  2341. "new_value": "",
  2342. "expected": {
  2343. "href": "sc:space %20#fragment",
  2344. "search": ""
  2345. }
  2346. },
  2347. {
  2348. "comment": "Trailing space should be encoded",
  2349. "href": "http://example.net",
  2350. "new_value": " ",
  2351. "expected": {
  2352. "href": "http://example.net/?%20",
  2353. "search": "?%20"
  2354. }
  2355. },
  2356. {
  2357. "comment": "Trailing C0 control should be encoded",
  2358. "href": "http://example.net",
  2359. "new_value": "\u0000",
  2360. "expected": {
  2361. "href": "http://example.net/?%00",
  2362. "search": "?%00"
  2363. }
  2364. }
  2365. ],
  2366. "hash": [
  2367. {
  2368. "href": "https://example.net",
  2369. "new_value": "main",
  2370. "expected": {
  2371. "href": "https://example.net/#main",
  2372. "hash": "#main"
  2373. }
  2374. },
  2375. {
  2376. "href": "https://example.net#nav",
  2377. "new_value": "main",
  2378. "expected": {
  2379. "href": "https://example.net/#main",
  2380. "hash": "#main"
  2381. }
  2382. },
  2383. {
  2384. "href": "https://example.net?lang=en-US",
  2385. "new_value": "##nav",
  2386. "expected": {
  2387. "href": "https://example.net/?lang=en-US##nav",
  2388. "hash": "##nav"
  2389. }
  2390. },
  2391. {
  2392. "href": "https://example.net?lang=en-US#nav",
  2393. "new_value": "#main",
  2394. "expected": {
  2395. "href": "https://example.net/?lang=en-US#main",
  2396. "hash": "#main"
  2397. }
  2398. },
  2399. {
  2400. "href": "https://example.net?lang=en-US#nav",
  2401. "new_value": "#",
  2402. "expected": {
  2403. "href": "https://example.net/?lang=en-US#",
  2404. "hash": ""
  2405. }
  2406. },
  2407. {
  2408. "href": "https://example.net?lang=en-US#nav",
  2409. "new_value": "",
  2410. "expected": {
  2411. "href": "https://example.net/?lang=en-US",
  2412. "hash": ""
  2413. }
  2414. },
  2415. {
  2416. "href": "http://example.net",
  2417. "new_value": "#foo bar",
  2418. "expected": {
  2419. "href": "http://example.net/#foo%20bar",
  2420. "hash": "#foo%20bar"
  2421. }
  2422. },
  2423. {
  2424. "href": "http://example.net",
  2425. "new_value": "#foo\"bar",
  2426. "expected": {
  2427. "href": "http://example.net/#foo%22bar",
  2428. "hash": "#foo%22bar"
  2429. }
  2430. },
  2431. {
  2432. "href": "http://example.net",
  2433. "new_value": "#foo<bar",
  2434. "expected": {
  2435. "href": "http://example.net/#foo%3Cbar",
  2436. "hash": "#foo%3Cbar"
  2437. }
  2438. },
  2439. {
  2440. "href": "http://example.net",
  2441. "new_value": "#foo>bar",
  2442. "expected": {
  2443. "href": "http://example.net/#foo%3Ebar",
  2444. "hash": "#foo%3Ebar"
  2445. }
  2446. },
  2447. {
  2448. "href": "http://example.net",
  2449. "new_value": "#foo`bar",
  2450. "expected": {
  2451. "href": "http://example.net/#foo%60bar",
  2452. "hash": "#foo%60bar"
  2453. }
  2454. },
  2455. {
  2456. "comment": "Simple percent-encoding; tabs and newlines are removed",
  2457. "href": "a:/",
  2458. "new_value": "\u0000\u0001\t\n\r\u001f !\"#$%&'()*+,-./09:;<=>?@AZ[\\]^_`az{|}~\u007f\u0080\u0081Éé",
  2459. "expected": {
  2460. "href": "a:/#%00%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9",
  2461. "hash": "#%00%01%1F%20!%22#$%&'()*+,-./09:;%3C=%3E?@AZ[\\]^_%60az{|}~%7F%C2%80%C2%81%C3%89%C3%A9"
  2462. }
  2463. },
  2464. {
  2465. "comment": "Percent-encode NULLs in fragment",
  2466. "href": "http://example.net",
  2467. "new_value": "a\u0000b",
  2468. "expected": {
  2469. "href": "http://example.net/#a%00b",
  2470. "hash": "#a%00b"
  2471. }
  2472. },
  2473. {
  2474. "comment": "Percent-encode NULLs in fragment",
  2475. "href": "non-spec:/",
  2476. "new_value": "a\u0000b",
  2477. "expected": {
  2478. "href": "non-spec:/#a%00b",
  2479. "hash": "#a%00b"
  2480. }
  2481. },
  2482. {
  2483. "comment": "Bytes already percent-encoded are left as-is",
  2484. "href": "http://example.net",
  2485. "new_value": "%c3%89té",
  2486. "expected": {
  2487. "href": "http://example.net/#%c3%89t%C3%A9",
  2488. "hash": "#%c3%89t%C3%A9"
  2489. }
  2490. },
  2491. {
  2492. "href": "javascript:alert(1)",
  2493. "new_value": "castle",
  2494. "expected": {
  2495. "href": "javascript:alert(1)#castle",
  2496. "hash": "#castle"
  2497. }
  2498. },
  2499. {
  2500. "comment": "Trailing spaces and opaque paths",
  2501. "href": "data:space #fragment",
  2502. "new_value": "",
  2503. "expected": {
  2504. "href": "data:space %20",
  2505. "pathname": "space %20",
  2506. "hash": ""
  2507. }
  2508. },
  2509. {
  2510. "href": "sc:space #fragment",
  2511. "new_value": "",
  2512. "expected": {
  2513. "href": "sc:space %20",
  2514. "pathname": "space %20",
  2515. "hash": ""
  2516. }
  2517. },
  2518. {
  2519. "comment": "Trailing spaces and opaque paths",
  2520. "href": "data:space ?query#fragment",
  2521. "new_value": "",
  2522. "expected": {
  2523. "href": "data:space %20?query",
  2524. "hash": ""
  2525. }
  2526. },
  2527. {
  2528. "href": "sc:space ?query#fragment",
  2529. "new_value": "",
  2530. "expected": {
  2531. "href": "sc:space %20?query",
  2532. "hash": ""
  2533. }
  2534. },
  2535. {
  2536. "comment": "Trailing space should be encoded",
  2537. "href": "http://example.net",
  2538. "new_value": " ",
  2539. "expected": {
  2540. "href": "http://example.net/#%20",
  2541. "hash": "#%20"
  2542. }
  2543. },
  2544. {
  2545. "comment": "Trailing C0 control should be encoded",
  2546. "href": "http://example.net",
  2547. "new_value": "\u0000",
  2548. "expected": {
  2549. "href": "http://example.net/#%00",
  2550. "hash": "#%00"
  2551. }
  2552. }
  2553. ],
  2554. "href": [
  2555. {
  2556. "href": "file:///var/log/system.log",
  2557. "new_value": "http://0300.168.0xF0",
  2558. "expected": {
  2559. "href": "http://192.168.0.240/",
  2560. "protocol": "http:"
  2561. }
  2562. }
  2563. ]
  2564. }