File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ public function convert(string $text, array $attribs = []): string
97
97
98
98
$ schemeRegex = sprintf ($ schemeRegex , $ this ->getSchemes (true ));
99
99
100
- $ regex = '/(([a-zA-Z]*=")* ' . $ schemeRegex . "[a-zA-Z0-9 \-\. ]+\.[a-zA-Z ]{2,3 }([\/a-zA-Z0-9\ -._~:?#\[\]@!$&'()*+,;=% \">]*)?)/ " ;
100
+ $ regex = '/(([a-zA-Z]*=")* ' . $ schemeRegex . "[\-\p{L}\p{N}\p{M} ]+\.[\p{L}\p{M} ]{2,}([\/\p{L}\p{N}\p{M}\ -._~:?#\[\]@!$&'()*+,;=% \">]*)?)/u " ;
101
101
102
102
return preg_replace_callback (
103
103
$ regex ,
Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ public function testConvert()
62
62
63
63
This is URL inline: http://example.com/path#top with test.
64
64
65
+ This is an IDN URL: http://dømi.fo
66
+
67
+ This is an IDN URL in Devanagari: http://सार्वभौमिक-स्वीकृति-परीक्षण.संगठन
68
+
65
69
This is URL in HTML:
66
70
<a href="http://example.com/path?foo[1]=a&foo[2]=b">LINK</a>
67
71
<a href="http://example.com/path?foo[1]=a&foo[2]=b">http://example.com/path?foo[1]=a&foo[2]=b</a>
@@ -92,6 +96,10 @@ public function testConvert()
92
96
93
97
This is URL inline: <a href="http://example.com/path#top">http://example.com/path#top</a> with test.
94
98
99
+ This is an IDN URL: <a href="http://dømi.fo">http://dømi.fo</a>
100
+
101
+ This is an IDN URL in Devanagari: <a href="http://सार्वभौमिक-स्वीकृति-परीक्षण.संगठन">http://सार्वभौमिक-स्वीकृति-परीक्षण.संगठन</a>
102
+
95
103
This is URL in HTML:
96
104
<a href="http://example.com/path?foo[1]=a&foo[2]=b">LINK</a>
97
105
<a href="http://example.com/path?foo[1]=a&foo[2]=b">http://example.com/path?foo[1]=a&foo[2]=b</a>
@@ -239,6 +247,15 @@ public function testLinkNoScheme()
239
247
$ this ->instance ->addScheme ('skype ' );
240
248
241
249
self ::assertEquals ('<a href=" ' . $ url . '"> ' . $ url . '</a> ' , $ this ->instance ->convert ($ url ));
250
+
251
+ $ url = 'dømi.fo ' ;
252
+
253
+ self ::assertEquals ('<a href="http:// ' . $ url . '"> ' . $ url . '</a> ' , $ this ->instance ->convert ($ url ));
254
+
255
+ $ url = 'dømi.fo/dømi ' ;
256
+
257
+ self ::assertEquals ('<a href="http:// ' . $ url . '"> ' . $ url . '</a> ' , $ this ->instance ->convert ($ url ));
258
+
242
259
}
243
260
244
261
/**
You can’t perform that action at this time.
0 commit comments