Update functions.php

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
This commit is contained in:
PVNFU-28 2021-02-16 13:56:54 -03:00 committed by Fredrick Brennan
parent 72f38933c2
commit 75236d6ae5

View File

@ -2069,7 +2069,7 @@ function markup(&$body, $track_cites = false, $op = false) {
if ($num_links > $config['max_links']) if ($num_links > $config['max_links'])
error($config['error']['toomanylinks']); error($config['error']['toomanylinks']);
} }
if ($config['markup_repair_tidy']) if ($config['markup_repair_tidy'])
$body = str_replace(' ', '  ', $body); $body = str_replace(' ', '  ', $body);
@ -2086,14 +2086,14 @@ function markup(&$body, $track_cites = false, $op = false) {
$tracked_cites = array(); $tracked_cites = array();
// Cites // 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']) { if (count($cites[0]) > $config['max_cites']) {
error($config['error']['toomanycites']); error($config['error']['toomanycites']);
} }
$skip_chars = 0; $skip_chars = 0;
$body_tmp = $body; $body_tmp = $body;
$search_cites = array(); $search_cites = array();
foreach ($cites as $matches) { foreach ($cites as $matches) {
$search_cites[] = '`id` = ' . $matches[2][0]; $search_cites[] = '`id` = ' . $matches[2][0];
@ -2102,12 +2102,12 @@ function markup(&$body, $track_cites = false, $op = false) {
$query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' . $query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' .
implode(' OR ', $search_cites), $board['uri'])) or error(db_error()); implode(' OR ', $search_cites), $board['uri'])) or error(db_error());
$cited_posts = array(); $cited_posts = array();
while ($cited = $query->fetch(PDO::FETCH_ASSOC)) { while ($cited = $query->fetch(PDO::FETCH_ASSOC)) {
$cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false; $cited_posts[$cited['id']] = $cited['thread'] ? $cited['thread'] : false;
} }
foreach ($cites as $matches) { foreach ($cites as $matches) {
$cite = $matches[2][0]; $cite = $matches[2][0];
@ -2133,21 +2133,21 @@ function markup(&$body, $track_cites = false, $op = false) {
} }
// Cross-board linking // 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']) { if (count($cites[0]) > $config['max_cites']) {
error($config['error']['toomanycross']); error($config['error']['toomanycross']);
} }
$skip_chars = 0; $skip_chars = 0;
$body_tmp = $body; $body_tmp = $body;
if (isset($cited_posts)) { if (isset($cited_posts)) {
// Carry found posts from local board >>X links // Carry found posts from local board >>X links
foreach ($cited_posts as $cite => $thread) { foreach ($cited_posts as $cite => $thread) {
$cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] . $cited_posts[$cite] = $config['root'] . $board['dir'] . $config['dir']['res'] .
($thread ? $thread : $cite) . '.html#' . $cite; ($thread ? $thread : $cite) . '.html#' . $cite;
} }
$cited_posts = array( $cited_posts = array(
$board['uri'] => $cited_posts $board['uri'] => $cited_posts
); );