Skip to content

Commit 61fcc81

Browse files
authored
Merge pull request #6618 from ytetsuro/fix/is-valid-valid-url-rule-when-has-newline
2 parents d8b5045 + 035ac6f commit 61fcc81

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

system/Validation/FormatRules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public function valid_url(?string $str = null): bool
293293
return false;
294294
}
295295

296-
if (preg_match('/^(?:([^:]*)\:)?\/\/(.+)$/', $str, $matches)) {
296+
if (preg_match('/\A(?:([^:]*)\:)?\/\/(.+)\z/', $str, $matches)) {
297297
if (! in_array($matches[1], ['http', 'https'], true)) {
298298
return false;
299299
}

tests/system/Validation/StrictRules/FormatRulesTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ public function urlProvider(): Generator
217217
false,
218218
false,
219219
],
220+
[
221+
"http://www.codeigniter.com\n",
222+
false,
223+
false,
224+
],
220225
];
221226
}
222227

0 commit comments

Comments
 (0)