/** * Make the name used for the quote safe for regex parsing * * @access protected * @param array preg_replace_callback Matches * @return string Output * @note This looks complicated (and is somewhat) but it's done this way to try to quote correctly users with ' in their names * @link http://community.invisionpower.com/tracker/issue-18588-bbcode-mistake-when-quoting-users-with-a-in-their-name */ protected function _makeNameSafe($matches) { $quote = $matches[1]; $name = $matches[2]; $next = ''; if (strpos($name, 'post=') !== false) { $next = substr($name, strpos($name, 'post=')); $name = substr($name, 0, strpos($name, 'post=') - 1); } if (strpos($name, 'date=') !== false) { $next = $next . ' ' . substr($name, strpos($name, 'date=')); $name = substr($name, 0, strpos($name, 'date=') - 1); } if (strpos($name, 'timestamp=') !== false) { $next = $next . ' ' . substr($name, strpos($name, 'timestamp=')); $name = substr($name, 0, strpos($name, 'timestamp=') - 1); } $name = substr($name, 0, -strlen($quote)); # Squeeze past the parser... $name = str_replace(array(''', "'"), "'", $name); $_last = $next ? ' ' . $next : ''; return 'name=' . $quote . IPSText::getTextClass('bbcode')->xssHtmlClean($this->_parent->stripAllTags(IPSText::stripUrls($name))) . $quote . $_last . ']'; }