Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
link
Commits
6939b336
Commit
6939b336
authored
Nov 14, 2006
by
Nathan Haug
Browse files
Corrections made to URL checking regex. Issue #89924.
parent
9847701b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
link.module
link.module
+11
-15
No files found.
link.module
View file @
6939b336
...
...
@@ -313,35 +313,31 @@ function link_cleanup_url ($url, $protocol = "http") {
* the following attributes: protocol, hostname, ip, and port.
*/
function
link_validate_link
(
$text
)
{
if
(
!
preg_match
(
if
(
preg_match
(
// protocol
'/^([a-z0-9][a-z0-9\.\-_]*:\/\/)?'
.
'('
.
// domains
'('
.
// domains
'(([a-z0-9]([a-z0-9\-_]*\.)+)(aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel|mobi|[a-z]{2}))'
.
// OR ip addresses
'|(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'
.
')'
.
')'
.
// port number
'(:([0-9]{1,4}))?'
.
// the rest of the path
"(\/[a-z0-9_\-\.~+%=&,$'():;*@]+)*"
.
// anchors
"\/?#?[a-z0-9_\-\.~+%=&,$'():;*@]*"
.
// the query string
"(\/?\?[a-z0-9+_\-\.\/%=&,$'():;*@]*)?"
.
// forward slash 0 or 1 times
'(\/)?'
.
// anchors
"(#[a-z0-9_\-\.~+%=&,$'():;*@]*)?"
.
// query string
"(\/?\?[a-z0-9+_\-\.\/%=&,$'():;*@]*)?"
.
// end of the expression, case insensitive
'$/i'
,
$text
,
$m
))
{
return
false
;
dsm
(
$m
);
return
true
;
}
else
{
$url
=
new
stdClass
();
$url
->
protocol
=
$m
[
2
];
$url
->
hostname
=
strtolower
(
$m
[
5
])
.
strtolower
(
$m
[
7
]);
$url
->
ip
=
$m
[
8
];
$url
->
port
=
$m
[
10
];
return
$url
;
return
false
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment