Merge pull request 'Hande crossboard invalid links with strikethrough' (#119) from cross-strikethrough into config

Reviewed-on: leftypol/leftypol#119
This commit is contained in:
Zankaria 2025-04-23 13:13:05 -05:00
commit 55508e6210

View file

@ -2228,20 +2228,15 @@ function markup(&$body, $track_cites = false) {
$clauses = array_unique($clauses);
if ($board['uri'] != $_board) {
if (!openBoard($_board)){
if (in_array($_board,array_keys($config['boards_alias']))){
$_board = $config['boards_alias'][$_board];
if (openBoard($_board)){
}
else {
if (!openBoard($_board)) {
if (\in_array($_board, \array_keys($config['boards_alias']))) {
$_board = $config['boards_alias'][$_board];
if (!openBoard($_board)) {
continue; // Unknown board
}
}
else {
}
} else {
continue; // Unknown board
}
}
}
@ -2282,38 +2277,31 @@ function markup(&$body, $track_cites = false) {
if ($cite) {
if (isset($cited_posts[$_board][$cite])) {
$link = $cited_posts[$_board][$cite];
if (isset($original_board)){
$replacement = '<a ' .
$replacement_board = $original_board ?? $_board;
$replacement = '<a ' .
($_board == $board['uri'] ?
'onclick="highlightReply(\''.$cite.'\', event);" '
: '') . 'href="' . $link . '">' .
'&gt;&gt;&gt;/' . $original_board . '/' . $cite .
'&gt;&gt;&gt;/' . $replacement_board . '/' . $cite .
'</a>';
if ($track_cites && $config['track_cites']) {
$tracked_cites[] = [ $_board, $cite ];
}
else {
$replacement = '<a ' .
($_board == $board['uri'] ?
'onclick="highlightReply(\''.$cite.'\', event);" '
: '') . 'href="' . $link . '">' .
'&gt;&gt;&gt;/' . $_board . '/' . $cite .
'</a>';
}
$body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
$skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);
if ($track_cites && $config['track_cites'])
$tracked_cites[] = array($_board, $cite);
} else {
$replacement = "<s>&gt;&gt;&gt;/$_board/$cite</s>";
}
} elseif(isset($crossboard_indexes[$_board])) {
} elseif (isset($crossboard_indexes[$_board])) {
$replacement = '<a href="' . $crossboard_indexes[$_board] . '">' .
'&gt;&gt;&gt;/' . $_board . '/' .
'</a>';
$body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
$skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);
} else {
$replacement = "<s>&gt;&gt;&gt;/$_board/$cite</s>";
}
$body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0]));
$skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);
}
}