fixed wrongly parsing link with @ symbol as username
This commit is contained in:
parent
787c58906e
commit
ef220fe537
@ -12,9 +12,11 @@ function postProcess(...callbacks) {
|
|||||||
|
|
||||||
function linkSanitize() {
|
function linkSanitize() {
|
||||||
$('.markdown-body a').each((_i, e) => {
|
$('.markdown-body a').each((_i, e) => {
|
||||||
href = (e.getAttribute('href')) ? _.unescape(e.getAttribute('href').toLowerCase()) : "";
|
href = (e.href) ? _.unescape(e.href.toLowerCase()) : "";
|
||||||
if (href.indexOf('javascript:') != -1) {
|
if (href.indexOf('javascript:') != -1) {
|
||||||
e.setAttribute('href', '#');
|
e.href = '#';
|
||||||
|
} else {
|
||||||
|
e.href = e.href.replace(/%40/, '@');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,12 @@ function parse_user_tag($markdown) {
|
|||||||
$regex = array(
|
$regex = array(
|
||||||
"code_block" => "/(`{1,3}[^`]*`{1,3})/",
|
"code_block" => "/(`{1,3}[^`]*`{1,3})/",
|
||||||
"email" => "/[^@\s]*@[^@\s]*\.[^@\s]*/",
|
"email" => "/[^@\s]*@[^@\s]*\.[^@\s]*/",
|
||||||
|
"url" => "/https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]+(\/\S*)/",
|
||||||
"username" => "/@(\w+)/"
|
"username" => "/@(\w+)/"
|
||||||
);
|
);
|
||||||
|
|
||||||
$tmp = preg_replace($regex["code_block"], " ", $markdown);
|
$tmp = preg_replace($regex["code_block"], " ", $markdown);
|
||||||
|
$tmp = preg_replace($regex['url'], " ", $tmp);
|
||||||
$tmp = preg_replace($regex["email"], " ", $tmp);
|
$tmp = preg_replace($regex["email"], " ", $tmp);
|
||||||
|
|
||||||
preg_match_all($regex["username"], $tmp, $username_list);
|
preg_match_all($regex["username"], $tmp, $username_list);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user