Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Sep 6, 2024
2 parents e570f46 + 0e283be commit 050a76a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion system/Helpers/url_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function safe_mailto(string $email, string $title = '', $attributes = ''): strin
function auto_link(string $str, string $type = 'both', bool $popup = false): string
{
// Find and replace any URLs.
if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
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)) {
// Set our target HTML if using popup links.
$target = ($popup) ? ' target="_blank"' : '';

Expand Down
8 changes: 8 additions & 0 deletions tests/system/Helpers/URLHelper/MiscUrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ public static function provideAutoLinkUrl(): iterable
'Visit www.example.com or email foo@bar.com',
'Visit <a href="http://www.example.com">www.example.com</a> or email foo@bar.com',
],
'trailing slash' => [
'Trailing slash: https://codeigniter.com/ fubar',
'Trailing slash: <a href="https://codeigniter.com/">https://codeigniter.com/</a> fubar',
],
];
}

Expand Down Expand Up @@ -629,6 +633,10 @@ public static function provideAutolinkBoth(): iterable
'Visit www.example.com or email foo@bar.com',
"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>",
],
'email starting with "www."' => [
'this is some text that includes www.email@domain.com which is causing an issue',
'this is some text that includes ' . safe_mailto('www.email@domain.com') . ' which is causing an issue',
],
];
}

Expand Down
4 changes: 4 additions & 0 deletions user_guide_src/source/changelogs/v4.5.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Deprecations
Bugs Fixed
**********

- **URL Helper:** The bug where the regular expression in :php:func:`auto_link()`
was old has been fixed. As a result of this fix, the same regular expression as
CodeIgniter 3 is now used.

See the repo's
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
for a complete list of bugs fixed.
17 changes: 9 additions & 8 deletions user_guide_src/source/helpers/html_helper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The following functions are available:

.. literalinclude:: html_helper/004.php

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

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

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

.. literalinclude:: html_helper/016.php

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

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

.. literalinclude:: html_helper/018.php

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

Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/libraries/validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ Rules for File Uploads
When you validate uploaded files, you must use the rules specifically created for
file validation.

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

Expand Down

0 comments on commit 050a76a

Please sign in to comment.