mirror of
https://github.com/typecho/typecho.git
synced 2025-01-17 20:48:42 +01:00
update hyperdown
This commit is contained in:
parent
834e4722a0
commit
99df2bae64
File diff suppressed because one or more lines are too long
@ -409,7 +409,7 @@
|
||||
text = this.parseInlineCallback(text);
|
||||
text = text.replace(/<([_a-z0-9-\.\+]+@[^@]+\.[a-z]{2,})>/ig, '<a href="mailto:$1">$1</a>');
|
||||
if (enableAutoLink) {
|
||||
regex = new RegExp("(^|[^\"])((https?):[" + pL + "_0-9-\\./%#!@\\?\\+=~\\|\\,&\\(\\)]+)($|[^\"])", 'ig');
|
||||
regex = new RegExp("(^|[^\"])((https?):[" + pL + "_0-9-\\./%#!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)($|[^\"])", 'ig');
|
||||
text = text.replace(regex, (function(_this) {
|
||||
return function() {
|
||||
var link, matches;
|
||||
@ -1164,7 +1164,7 @@
|
||||
|
||||
Parser.prototype.cleanUrl = function(url) {
|
||||
var matches, regexUrl, regexWord;
|
||||
regexUrl = new RegExp("^\\s*((http|https|ftp|mailto):[" + pL + "_a-z0-9-:\\.\\*/%#;!@\\?\\+=~\\|\\,&\\(\\)]+)", 'i');
|
||||
regexUrl = new RegExp("^\\s*((http|https|ftp|mailto):[" + pL + "_a-z0-9-:\\.\\*/%#;!@\\?\\[\\]\\+=~\\|\\,&\\(\\)]+)", 'i');
|
||||
regexWord = new RegExp("^\\s*([" + pL + "_a-z0-9-:\\.\\*/%#!@\\?\\+=~\\|\\,&]+)", 'i');
|
||||
if (!!(matches = url.match(regexUrl))) {
|
||||
return matches[1];
|
||||
|
@ -385,8 +385,8 @@ class HyperDown
|
||||
"/(^|[^\\\])(`+)(.+?)\\2/",
|
||||
function ($matches) use ($self) {
|
||||
return $matches[1] . $self->makeHolder(
|
||||
'<code>' . htmlspecialchars($matches[3]) . '</code>'
|
||||
);
|
||||
'<code>' . htmlspecialchars($matches[3]) . '</code>'
|
||||
);
|
||||
},
|
||||
$text
|
||||
);
|
||||
@ -396,8 +396,8 @@ class HyperDown
|
||||
"/(^|[^\\\])(\\$+)(.+?)\\2/",
|
||||
function ($matches) use ($self) {
|
||||
return $matches[1] . $self->makeHolder(
|
||||
$matches[2] . htmlspecialchars($matches[3]) . $matches[2]
|
||||
);
|
||||
$matches[2] . htmlspecialchars($matches[3]) . $matches[2]
|
||||
);
|
||||
},
|
||||
$text
|
||||
);
|
||||
@ -433,8 +433,8 @@ class HyperDown
|
||||
"/<(\/?)([a-z0-9-]+)(\s+[^>]*)?>/i",
|
||||
function ($matches) use ($self, $whiteList) {
|
||||
if ($self->_html || false !== stripos(
|
||||
'|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
|
||||
)) {
|
||||
'|' . $self->_commonWhiteList . '|' . $whiteList . '|', '|' . $matches[2] . '|'
|
||||
)) {
|
||||
return $self->makeHolder($matches[0]);
|
||||
} else {
|
||||
return $self->makeHolder(htmlspecialchars($matches[0]));
|
||||
@ -1071,7 +1071,7 @@ class HyperDown
|
||||
private function parseBlockMh($block, $key, $line, &$state, $lines)
|
||||
{
|
||||
if (preg_match("/^\s*((=|-){2,})\s*$/", $line, $matches)
|
||||
&& ($block && $block[0] == "normal" && !preg_match("/^\s*$/", $lines[$block[2]]))) { // check if last line isn't empty
|
||||
&& ($block && $block[0] == "normal" && !preg_match("/^\s*$/", $lines[$block[2]]))) { // check if last line isn't empty
|
||||
if ($this->isBlock('normal')) {
|
||||
$this->backBlock(1, 'mh', $matches[1][0] == '=' ? 1 : 2)
|
||||
->setBlock($key)
|
||||
@ -1652,7 +1652,7 @@ class HyperDown
|
||||
*/
|
||||
public function cleanUrl($url)
|
||||
{
|
||||
if (preg_match("/^\s*((http|https|ftp|mailto):[\p{L}_a-z0-9-:\.\*\/%#;!@\?\+=~\|\,&\(\)]+)/iu", $url, $matches)) {
|
||||
if (preg_match("/^\s*((http|https|ftp|mailto):[\p{L}_a-z0-9-:\.\*\/%#;!@\?\+=~\|\,&\(\)\[\]]+)/iu", $url, $matches)) {
|
||||
return $matches[1];
|
||||
} else if (preg_match("/^\s*([\p{L}_a-z0-9-:\.\*\/%#!@\?\+=~\|\,&]+)/iu", $url, $matches)) {
|
||||
return $matches[1];
|
||||
@ -1794,4 +1794,3 @@ class HyperDown
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user