File tree 3 files changed +71
-13
lines changed
3 files changed +71
-13
lines changed Original file line number Diff line number Diff line change @@ -461,6 +461,13 @@ int32_t ToUnicode(MaybeStackBuffer<char>* buf,
461
461
&status);
462
462
}
463
463
464
+ // UTS #46's ToUnicode operation applies no validation of domain name length
465
+ // (nor a flag requesting it to do so, like VerifyDnsLength for ToASCII). For
466
+ // that reason, unlike ToASCII below, ICU4C correctly accepts long domain
467
+ // names. However, ICU4C still sets the EMPTY_LABEL error in contrary to UTS
468
+ // #46. Therefore, explicitly filters out that error here.
469
+ info.errors &= ~UIDNA_ERROR_EMPTY_LABEL;
470
+
464
471
if (U_FAILURE (status) || (!lenient && info.errors != 0 )) {
465
472
len = -1 ;
466
473
buf->SetLength (0 );
@@ -500,6 +507,16 @@ int32_t ToASCII(MaybeStackBuffer<char>* buf,
500
507
&status);
501
508
}
502
509
510
+ // The WHATWG URL "domain to ASCII" algorithm explicitly sets the
511
+ // VerifyDnsLength flag to false, which disables the domain name length
512
+ // verification step in ToASCII (as specified by UTS #46). Unfortunately,
513
+ // ICU4C's IDNA module does not support disabling this flag through `options`,
514
+ // so just filter out the errors that may be caused by the verification step
515
+ // afterwards.
516
+ info.errors &= ~UIDNA_ERROR_EMPTY_LABEL;
517
+ info.errors &= ~UIDNA_ERROR_LABEL_TOO_LONG;
518
+ info.errors &= ~UIDNA_ERROR_DOMAIN_NAME_TOO_LONG;
519
+
503
520
if (U_FAILURE (status) || (!lenient && info.errors != 0 )) {
504
521
len = -1 ;
505
522
buf->SetLength (0 );
Original file line number Diff line number Diff line change @@ -182,23 +182,18 @@ module.exports = {
182
182
ascii : 'xn--vitnam-jk8b.icom.museum' ,
183
183
unicode : 'việtnam.icom.museum'
184
184
} ,
185
- // long URL
186
- {
187
- ascii : `${ `${ 'a' . repeat ( 63 ) } .` . repeat ( 3 ) } com` ,
188
- unicode : `${ `${ 'a' . repeat ( 63 ) } .` . repeat ( 3 ) } com`
189
- }
190
- ] ,
191
- invalid : [
192
185
// long label
193
186
{
194
- url : `${ 'a' . repeat ( 64 ) } .com` ,
195
- mode : 'ascii'
187
+ ascii : `${ 'a' . repeat ( 64 ) } .com` ,
188
+ unicode : ` ${ 'a' . repeat ( 64 ) } .com` ,
196
189
} ,
197
190
// long URL
198
191
{
199
- url : `${ `${ 'a' . repeat ( 63 ) } .` . repeat ( 4 ) } com` ,
200
- mode : 'ascii'
201
- } ,
192
+ ascii : `${ `${ 'a' . repeat ( 64 ) } .` . repeat ( 4 ) } com` ,
193
+ unicode : `${ `${ 'a' . repeat ( 64 ) } .` . repeat ( 4 ) } com`
194
+ }
195
+ ] ,
196
+ invalid : [
202
197
// invalid character
203
198
{
204
199
url : '\ufffd.com' ,
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
3
/* WPT Refs:
4
- https://github.com/w3c/web-platform-tests/blob/3eff1bd /url/urltestdata.json
4
+ https://github.com/w3c/web-platform-tests/blob/3afae94 /url/urltestdata.json
5
5
License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html
6
6
*/
7
7
module . exports =
@@ -3789,6 +3789,52 @@ module.exports =
3789
3789
"search" : "" ,
3790
3790
"hash" : ""
3791
3791
} ,
3792
+ "Domains with empty labels" ,
3793
+ {
3794
+ "input" : "http://./" ,
3795
+ "base" : "about:blank" ,
3796
+ "href" : "http://./" ,
3797
+ "origin" : "http://." ,
3798
+ "protocol" : "http:" ,
3799
+ "username" : "" ,
3800
+ "password" : "" ,
3801
+ "host" : "." ,
3802
+ "hostname" : "." ,
3803
+ "port" : "" ,
3804
+ "pathname" : "/" ,
3805
+ "search" : "" ,
3806
+ "hash" : ""
3807
+ } ,
3808
+ {
3809
+ "input" : "http://../" ,
3810
+ "base" : "about:blank" ,
3811
+ "href" : "http://../" ,
3812
+ "origin" : "http://.." ,
3813
+ "protocol" : "http:" ,
3814
+ "username" : "" ,
3815
+ "password" : "" ,
3816
+ "host" : ".." ,
3817
+ "hostname" : ".." ,
3818
+ "port" : "" ,
3819
+ "pathname" : "/" ,
3820
+ "search" : "" ,
3821
+ "hash" : ""
3822
+ } ,
3823
+ {
3824
+ "input" : "http://0..0x300/" ,
3825
+ "base" : "about:blank" ,
3826
+ "href" : "http://0..0x300/" ,
3827
+ "origin" : "http://0..0x300" ,
3828
+ "protocol" : "http:" ,
3829
+ "username" : "" ,
3830
+ "password" : "" ,
3831
+ "host" : "0..0x300" ,
3832
+ "hostname" : "0..0x300" ,
3833
+ "port" : "" ,
3834
+ "pathname" : "/" ,
3835
+ "search" : "" ,
3836
+ "hash" : ""
3837
+ } ,
3792
3838
"Broken IPv6" ,
3793
3839
{
3794
3840
"input" : "http://[www.google.com]/" ,
You can’t perform that action at this time.
0 commit comments