Skip to content

Commit 050a76a

Browse files
committed
Merge remote-tracking branch 'upstream/develop' into 4.6
2 parents e570f46 + 0e283be commit 050a76a

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

system/Helpers/url_helper.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ function safe_mailto(string $email, string $title = '', $attributes = ''): strin
351351
function auto_link(string $str, string $type = 'both', bool $popup = false): string
352352
{
353353
// Find and replace any URLs.
354-
if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
354+
if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[a-z0-9]+(-+[a-z0-9]+)*(\.[a-z0-9]+(-+[a-z0-9]+)*)+(/([^\s()<>;]+\w)?/?)?#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
355355
// Set our target HTML if using popup links.
356356
$target = ($popup) ? ' target="_blank"' : '';
357357

tests/system/Helpers/URLHelper/MiscUrlTest.php

+8
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@ public static function provideAutoLinkUrl(): iterable
533533
'Visit www.example.com or email [email protected]',
534534
'Visit <a href="http://www.example.com">www.example.com</a> or email [email protected]',
535535
],
536+
'trailing slash' => [
537+
'Trailing slash: https://codeigniter.com/ fubar',
538+
'Trailing slash: <a href="https://codeigniter.com/">https://codeigniter.com/</a> fubar',
539+
],
536540
];
537541
}
538542

@@ -629,6 +633,10 @@ public static function provideAutolinkBoth(): iterable
629633
'Visit www.example.com or email [email protected]',
630634
"Visit <a href=\"http://www.example.com\">www.example.com</a> or email <script>var l=new Array();l[0] = '>';l[1] = 'a';l[2] = '/';l[3] = '<';l[4] = '|109';l[5] = '|111';l[6] = '|99';l[7] = '|46';l[8] = '|114';l[9] = '|97';l[10] = '|98';l[11] = '|64';l[12] = '|111';l[13] = '|111';l[14] = '|102';l[15] = '>';l[16] = '\"';l[17] = '|109';l[18] = '|111';l[19] = '|99';l[20] = '|46';l[21] = '|114';l[22] = '|97';l[23] = '|98';l[24] = '|64';l[25] = '|111';l[26] = '|111';l[27] = '|102';l[28] = ':';l[29] = 'o';l[30] = 't';l[31] = 'l';l[32] = 'i';l[33] = 'a';l[34] = 'm';l[35] = '\"';l[36] = '=';l[37] = 'f';l[38] = 'e';l[39] = 'r';l[40] = 'h';l[41] = ' ';l[42] = 'a';l[43] = '<';for (var i = l.length-1; i >= 0; i=i-1) {if (l[i].substring(0, 1) === '|') document.write(\"&#\"+unescape(l[i].substring(1))+\";\");else document.write(unescape(l[i]));}</script>",
631635
],
636+
'email starting with "www."' => [
637+
'this is some text that includes [email protected] which is causing an issue',
638+
'this is some text that includes ' . safe_mailto('[email protected]') . ' which is causing an issue',
639+
],
632640
];
633641
}
634642

user_guide_src/source/changelogs/v4.5.5.rst

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Deprecations
3030
Bugs Fixed
3131
**********
3232

33+
- **URL Helper:** The bug where the regular expression in :php:func:`auto_link()`
34+
was old has been fixed. As a result of this fix, the same regular expression as
35+
CodeIgniter 3 is now used.
36+
3337
See the repo's
3438
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
3539
for a complete list of bugs fixed.

user_guide_src/source/helpers/html_helper.rst

+9-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The following functions are available:
5252

5353
.. literalinclude:: html_helper/004.php
5454

55-
.. php:function:: img_data([$src = ''[, $indexPage = false[, $attributes = '']]])
55+
.. php:function:: img_data($path[, $mime = null])
5656
5757
:param string $path: Path to the image file
5858
:param string|null $mime: MIME type to use, or null to guess
@@ -260,7 +260,7 @@ The following functions are available:
260260

261261
Identical to :php:func:`video()`, only it produces ``<audio>`` element instead of ``<video>``.
262262

263-
.. php:function:: source($src = ''[, $type = false[, $attributes = '']])
263+
.. php:function:: source($src, $type = 'unknown', $attributes = '', $indexPage = false)
264264
265265
:param string $src: The path of the media resource
266266
:param bool $type: The MIME-type of the resource with optional codecs parameters
@@ -287,7 +287,7 @@ The following functions are available:
287287

288288
.. literalinclude:: html_helper/016.php
289289

290-
.. php:function:: object($data = ''[, $type = false[, $attributes = '']])
290+
.. php:function:: object($data[, $type = 'unknown'[, $attributes = ''[, $params = [][, $indexPage = false]]]])
291291
292292
:param string $data: A resource URL
293293
:param bool $type: Content-type of the resource
@@ -312,7 +312,7 @@ The following functions are available:
312312
<param name="hello" type="ref" value="world" class="test" />
313313
</object>
314314

315-
.. php:function:: param($name = ''[, $type = false[, $attributes = '']])
315+
.. php:function:: param($name, $value[, $type = 'ref'[, $attributes = '']])
316316
317317
:param string $name: The name of the parameter
318318
:param string $value: The value of the parameter
@@ -325,11 +325,12 @@ The following functions are available:
325325

326326
.. literalinclude:: html_helper/018.php
327327

328-
.. php:function:: track($name = ''[, $type = false[, $attributes = '']])
328+
.. php:function:: track($src, $kind, $srcLanguage, $label)
329329
330-
:param string $name: The name of the parameter
331-
:param string $value: The value of the parameter
332-
:param array $attributes: HTML attributes
330+
:param string $src: The path of the track (.vtt file)
331+
:param string $kind: The kind of timed track
332+
:param string $srcLanguage: The language of the timed track
333+
:param string $label: A user-readable title for the timed track
333334
:returns: An HTML track element
334335
:rtype: string
335336

user_guide_src/source/libraries/validation.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ Rules for File Uploads
10501050
When you validate uploaded files, you must use the rules specifically created for
10511051
file validation.
10521052

1053-
.. important:: Only rules that listed in the table below can be used to validate
1053+
.. important:: Only rules that are listed in the table below can be used to validate
10541054
files. Therefore, adding any general rules, like ``permit_empty``, to file
10551055
validation rules array or string, the file validation will not work correctly.
10561056

0 commit comments

Comments
 (0)