update hyperdown

This commit is contained in:
joyqi 2021-06-18 16:52:59 +08:00
parent ac74c6e0cb
commit 50c23c44c5
4 changed files with 16 additions and 10 deletions

View File

@ -1,6 +1,12 @@
name: Typecho Build Dev Ci
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
php:

File diff suppressed because one or more lines are too long

View File

@ -406,12 +406,12 @@
text = this.parseInlineCallback(text);
text = text.replace(/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/ig, '<a href="mailto:$1">$1</a>');
if (enableAutoLink) {
text = text.replace(/(^|[^\"])((https?):\S+)($|[^\"])/ig, (function(_this) {
text = text.replace(/(^|[^\"])(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*))($|[^\"])/g, (function(_this) {
return function() {
var link, matches;
matches = 1 <= arguments.length ? slice.call(arguments, 0) : [];
link = _this.call('parseLink', matches[2]);
return matches[1] + "<a href=\"" + matches[2] + "\">" + link + "</a>" + matches[4];
return matches[1] + "<a href=\"" + matches[2] + "\">" + link + "</a>" + matches[5];
};
})(this));
}
@ -1139,9 +1139,9 @@
Parser.prototype.cleanUrl = function(url) {
var matches;
if (!!(matches = url.match(/^\s*((http|https|ftp|mailto):\S+)/i))) {
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*(\S+)/))) {
} else if (!!(matches = url.match(/^\s*([-a-zA-Z0-9()@:%_\+.~#?&\/=]+)/))) {
return matches[1];
} else {
return '#';

View File

@ -537,10 +537,10 @@ class HyperDown
// autolink url
if ($enableAutoLink) {
$text = preg_replace_callback(
"/(^|[^\"])((https?):\S+)($|[^\"])/i",
"/(^|[^\"])(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*))($|[^\"])/",
function ($matches) use ($self) {
$link = $self->call('parseLink', $matches[2]);
return "{$matches[1]}<a href=\"{$matches[2]}\">{$link}</a>{$matches[4]}";
return "{$matches[1]}<a href=\"{$matches[2]}\">{$link}</a>{$matches[5]}";
},
$text
);
@ -1627,9 +1627,9 @@ class HyperDown
*/
public function cleanUrl($url)
{
if (preg_match("/^\s*((http|https|ftp|mailto):\S+)/i", $url, $matches)) {
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*(\S+)/i", $url, $matches)) {
} elseif (preg_match("/^\s*([-a-zA-Z0-9()@:%_\+.~#?&\/=]+)/", $url, $matches)) {
return $matches[1];
} else {
return '#';