Skip to content

Commit

Permalink
Update functions.php
Browse files Browse the repository at this point in the history
current regex consumes the space after a post quote, instead of merely checking that it's there. As a result textually consecutive post quotes, which the source calls cites, cannot be separated by a single space. This fixes that
  • Loading branch information
PVNFU-28 authored and ctrlcctrlv committed Aug 20, 2022
1 parent 72f3893 commit 75236d6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions inc/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2069,7 +2069,7 @@ function markup(&$body, $track_cites = false, $op = false) {
if ($num_links > $config['max_links'])
error($config['error']['toomanylinks']);
}

if ($config['markup_repair_tidy'])
$body = str_replace(' ', '  ', $body);

Expand All @@ -2086,14 +2086,14 @@ function markup(&$body, $track_cites = false, $op = false) {
$tracked_cites = array();

// Cites
if (isset($board) && preg_match_all('/(^|\s)>>(\d+?)([\s,.)?]|$)/m', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
if (isset($board) && preg_match_all('/(^|\s)>>(\d+?)((?=[\s,.)?!])|$)/m', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
if (count($cites[0]) > $config['max_cites']) {
error($config['error']['toomanycites']);
}

$skip_chars = 0;
$body_tmp = $body;

$search_cites = array();
foreach ($cites as $matches) {
$search_cites[] = '`id` = ' . $matches[2][0];
Expand All @@ -2102,12 +2102,12 @@ function markup(&$body, $track_cites = false, $op = false) {

$query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' .
implode(' OR ', $search_cites), $board['uri'])) or error(db_error());

$cited_posts = array();
while ($cited = $query->fetch(PDO::FETCH_ASSOC)) {
$cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false;
}

foreach ($cites as $matches) {
$cite = $matches[2][0];

Expand All @@ -2133,21 +2133,21 @@ function markup(&$body, $track_cites = false, $op = false) {
}

// Cross-board linking
if (preg_match_all('/(^|\s)>>>\/(' . $config['board_regex'] . 'f?)\/(\d+)?([\s,.)?]|$)/um', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
if (preg_match_all('/(^|\s)>>>\/(' . $config['board_regex'] . 'f?)\/(\d+)?((?=[\s,.)?!])|$)/um', $body, $cites, PREG_SET_ORDER | PREG_OFFSET_CAPTURE)) {
if (count($cites[0]) > $config['max_cites']) {
error($config['error']['toomanycross']);
}

$skip_chars = 0;
$body_tmp = $body;

if (isset($cited_posts)) {
// Carry found posts from local board >>X links
foreach ($cited_posts as $cite => $thread) {
$cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] .
($thread ? $thread : $cite) . '.html#' . $cite;
}

$cited_posts = array(
$board['uri'] => $cited_posts
);
Expand Down

0 comments on commit 75236d6

Please sign in to comment.