1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 07:07:51 +02:00

fix custom bbcode html replacement to correctly replace references

It failed if there was a number directly after the token, resulting in $12345, where $1 was needed. Fixed by using ${x}

also made sure that newlines within the html replacement are not replaced with <br />.


git-svn-id: file:///svn/phpbb/trunk@6391 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
Meik Sievertsen 2006-09-23 11:37:05 +00:00
parent d62e93ee30
commit 70dffaacbd
2 changed files with 8 additions and 2 deletions

View File

@ -290,7 +290,7 @@ class acp_bbcodes
if (preg_match_all('/(?<!\\\\)\$([0-9]+)/', $replace, $repad))
{
$repad = $pad + sizeof(array_unique($repad[0]));
$replace = preg_replace('/(?<!\\\\)\$([0-9]+)/e', "'\$' . (\$1 + \$pad)", $replace);
$replace = preg_replace('/(?<!\\\\)\$([0-9]+)/e', "'\${' . (\$1 + \$pad) . '}'", $replace);
$pad = $repad;
}
@ -320,7 +320,7 @@ class acp_bbcodes
$fp_replace = str_replace($token, $replace, $fp_replace);
$sp_match = str_replace(preg_quote($token, '!'), '(.*?)', $sp_match);
$sp_replace = str_replace($token, '$' . ($n + 1), $sp_replace);
$sp_replace = str_replace($token, '${' . ($n + 1) . '}', $sp_replace);
}
$fp_match = '!' . $fp_match . '!' . $modifiers;

View File

@ -155,6 +155,12 @@ class bbcode
while ($row = $db->sql_fetchrow($result))
{
// To circumvent replacing newlines with <br /> for the generated html,
// we just remove newlines here. We do not do this within the admin panel to
// let the admin lay out his html code nicely
$row['bbcode_tpl'] = str_replace(array("\n", "\r"), '', $row['bbcode_tpl']);
$row['second_pass_replace'] = str_replace(array("\n", "\r"), '', $row['second_pass_replace']);
$rowset[$row['bbcode_id']] = $row;
}
$db->sql_freeresult($result);