diff --git a/Sources/MoveTopic.php b/Sources/MoveTopic.php index 64463ac27f..8190b698b4 100644 --- a/Sources/MoveTopic.php +++ b/Sources/MoveTopic.php @@ -266,7 +266,7 @@ function MoveTopic2() { // Replace tokens with links in the reason. $reason_replacements = array( - $txt['movetopic_auto_board'] => '[url="' . $scripturl . '?board=' . $_POST['toboard'] . '.0"]' . $board_name . '[/url]', + $txt['movetopic_auto_board'] => '[url="' . $scripturl . '?board=' . $_POST['toboard'] . '.0"]' . $board_name . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]', ); @@ -277,7 +277,7 @@ function MoveTopic2() // Make sure we catch both languages in the reason. $reason_replacements += array( - $txt['movetopic_auto_board'] => '[url="' . $scripturl . '?board=' . $_POST['toboard'] . '.0"]' . $board_name . '[/url]', + $txt['movetopic_auto_board'] => '[url="' . $scripturl . '?board=' . $_POST['toboard'] . '.0"]' . $board_name . '[/url]', $txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]', ); } diff --git a/Sources/SplitTopics.php b/Sources/SplitTopics.php index d0a77b3181..a33d6f9a88 100644 --- a/Sources/SplitTopics.php +++ b/Sources/SplitTopics.php @@ -1401,7 +1401,7 @@ function MergeExecute($topics = array()) { // Replace tokens with links in the reason. $reason_replacements = array( - $txt['movetopic_auto_topic'] => '[iurl="' . $scripturl . '?topic=' . $id_topic . '.0"]' . $target_subject . '[/iurl]', + $txt['movetopic_auto_topic'] => '[iurl="' . $scripturl . '?topic=' . $id_topic . '.0"]' . $target_subject . '[/iurl]', ); // Should be in the boardwide language. @@ -1411,7 +1411,7 @@ function MergeExecute($topics = array()) // Make sure we catch both languages in the reason. $reason_replacements += array( - $txt['movetopic_auto_topic'] => '[iurl="' . $scripturl . '?topic=' . $id_topic . '.0"]' . $target_subject . '[/iurl]', + $txt['movetopic_auto_topic'] => '[iurl="' . $scripturl . '?topic=' . $id_topic . '.0"]' . $target_subject . '[/iurl]', ); } diff --git a/Sources/Subs.php b/Sources/Subs.php index d1f5dbbd1c..3e0b7c9df3 100644 --- a/Sources/Subs.php +++ b/Sources/Subs.php @@ -3657,17 +3657,21 @@ function($matches) use ($schemes) // The value may be quoted for some tags - check. if (isset($tag['quoted'])) { - $quoted = substr($message, $pos1, 6) == '"'; + // Anything passed through the preparser will use ", + // but we need to handle raw quotation marks too. + $quot = substr($message, $pos1, 1) === '"' ? '"' : '"'; + + $quoted = substr($message, $pos1, strlen($quot)) == $quot; if ($tag['quoted'] != 'optional' && !$quoted) continue; if ($quoted) - $pos1 += 6; + $pos1 += strlen($quot); } else $quoted = false; - $pos2 = strpos($message, $quoted == false ? ']' : '"]', $pos1); + $pos2 = strpos($message, $quoted == false ? ']' : $quot . ']', $pos1); if ($pos2 === false) continue; @@ -3676,7 +3680,7 @@ function($matches) use ($schemes) continue; $data = array( - substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))), + substr($message, $pos2 + ($quoted == false ? 1 : 1 + strlen($quot)), $pos3 - ($pos2 + ($quoted == false ? 1 : 1 + strlen($quot)))), substr($message, $pos1, $pos2 - $pos1) ); @@ -3759,29 +3763,32 @@ function($matches) use ($schemes) // The value may be quoted for some tags - check. if (isset($tag['quoted'])) { - $quoted = substr($message, $pos1, 6) == '"'; + // Will normally be '"' but might be '"'. + $quot = substr($message, $pos1, 1) === '"' ? '"' : '"'; + + $quoted = substr($message, $pos1, strlen($quot)) == $quot; if ($tag['quoted'] != 'optional' && !$quoted) continue; if ($quoted) - $pos1 += 6; + $pos1 += strlen($quot); } else $quoted = false; if ($quoted) { - $end_of_value = strpos($message, '"]', $pos1); - $nested_tag = strpos($message, '="', $pos1); + $end_of_value = strpos($message, $quot . ']', $pos1); + $nested_tag = strpos($message, '=' . $quot, $pos1); // Check so this is not just an quoted url ending with a = - if ($nested_tag && substr($message, $nested_tag, 8) == '="]') + if ($nested_tag && substr($message, $nested_tag, 2 + strlen($quot)) == '=' . $quot . ']') $nested_tag = false; if ($nested_tag && $nested_tag < $end_of_value) // Nested tag with quoted value detected, use next end tag - $nested_tag_pos = strpos($message, $quoted == false ? ']' : '"]', $pos1) + 6; + $nested_tag_pos = strpos($message, $quoted == false ? ']' : $quot . ']', $pos1) + strlen($quot); } - $pos2 = strpos($message, $quoted == false ? ']' : '"]', isset($nested_tag_pos) ? $nested_tag_pos : $pos1); + $pos2 = strpos($message, $quoted == false ? ']' : $quot . ']', isset($nested_tag_pos) ? $nested_tag_pos : $pos1); if ($pos2 === false) continue; @@ -3800,7 +3807,7 @@ function($matches) use ($schemes) $open_tags[] = $tag; $code = strtr($tag['before'], array('$1' => $data)); - $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + ($quoted == false ? 1 : 7)); + $message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + ($quoted == false ? 1 : 1 + strlen($quot))); $pos += strlen($code) - 1 + 2; }