fix hyperdown

This commit is contained in:
joyqi 2021-06-22 12:15:00 +08:00
parent db6825a33d
commit 70068ed5a1
3 changed files with 9 additions and 12 deletions

File diff suppressed because one or more lines are too long

View File

@ -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) {

View File

@ -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;
}
/**