diff --git a/inc/functions.php b/inc/functions.php index 4ecf249d..b931ca78 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -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); @@ -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]; @@ -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]; @@ -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 );