mirror of
https://github.com/typecho/typecho.git
synced 2025-01-29 18:27:57 +01:00
fix hyperdown
This commit is contained in:
parent
db6825a33d
commit
70068ed5a1
File diff suppressed because one or more lines are too long
@ -1138,14 +1138,11 @@
|
||||
};
|
||||
|
||||
Parser.prototype.cleanUrl = function(url) {
|
||||
var matches;
|
||||
if (!!(matches = url.match(/^\s*(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*))/))) {
|
||||
return matches[1];
|
||||
} else if (!!(matches = url.match(/^\s*([-a-zA-Z0-9()@:%_\+.~#?&\/=]+)/))) {
|
||||
return matches[1];
|
||||
} else {
|
||||
url = url.replace(/["'<>\s]/g, '');
|
||||
if ((url.match(/^\w+:/i)) && !(url.match(/^https?:/i))) {
|
||||
return '#';
|
||||
}
|
||||
return url;
|
||||
};
|
||||
|
||||
Parser.prototype.escapeBracket = function(str) {
|
||||
|
@ -1627,13 +1627,13 @@ class HyperDown
|
||||
*/
|
||||
public function cleanUrl($url)
|
||||
{
|
||||
if (preg_match("/^\s*(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*))/", $url, $matches)) {
|
||||
return $matches[1];
|
||||
} elseif (preg_match("/^\s*([-a-zA-Z0-9()@:%_\+.~#?&\/=]+)/", $url, $matches)) {
|
||||
return $matches[1];
|
||||
} else {
|
||||
$url = preg_replace("/[\"'<>\s]/", '', $url);
|
||||
|
||||
if (preg_match("/^\w+:/i", $url) && !preg_match("/^https?:/i", $url)) {
|
||||
return '#';
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user