Skip to content

Commit

Permalink
Wrong invalid URL check; closes #7642 (#7648)
Browse files Browse the repository at this point in the history
* Wrong invalid URL check; closes #7642

* Improve URL checks

Co-authored-by: Cédric Anne <cedric.anne@gmail.com>

Co-authored-by: Cédric Anne <cedric.anne@gmail.com>
  • Loading branch information
trasher and cedric-anne authored Jul 10, 2020
1 parent b4bdbb7 commit d76b785
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion inc/toolbox.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -3462,7 +3462,7 @@ public static function isAPIDeprecated(string $class): bool {
*/
public static function isValidWebUrl($url): bool {
return (preg_match(
'#^http[s]?://[a-z0-9\-_]+(\.([a-z0-9\-]+\.)?[a-z]+)?(:\d+)?(/.*)?$#i',
'#^http[s]?://[a-z0-9\-_]+(\.([a-z0-9\-]+\.)*[a-z]+)?(:\d+)?(/.*)?$#i',
$url
) === 1);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/units/Toolbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ protected function urlProvider() {
['http://my.host.com:8080 /', false],
['http://my.host.com: 8080/', false],
['http://my.host.com :8080/', false],
['http://helpdesk.global.glpi-project.org', true],
['http://dev.helpdesk.global.glpi-project.org', true],
];
}

Expand Down

0 comments on commit d76b785

Please sign in to comment.