summary refs log tree commit diff stats
path: root/includes
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2008-12-13 10:18:55 -0500
committerStarla Insigna <hatkirby@fourisland.com>2008-12-13 10:18:55 -0500
commitf037e1d6baa069b324b7a0fd6eaffbdfb5c6f4dc (patch)
treec638a2e85e8f906746729d44e2e1c3fd7d100e95 /includes
parent1f975f948841eacd2cca2da39cfbe04d10e0e137 (diff)
downloadfourisland-f037e1d6baa069b324b7a0fd6eaffbdfb5c6f4dc.tar.gz
fourisland-f037e1d6baa069b324b7a0fd6eaffbdfb5c6f4dc.tar.bz2
fourisland-f037e1d6baa069b324b7a0fd6eaffbdfb5c6f4dc.zip
Fixed BBCode parsing glitch
As previously seen in the 24 Ways post, there was a strange BBCode parsing glitch caused by a few circumstances. There had to be a BBCode tag that
had a parametered definition and a non-parametered definition. Both had to appear in the same post and the parametered had to appear before the
non-parametered.

Because the Four Island BBCode parsing system parses non-parametered tags first, it finds the opening tag of the non-parametered tag first, but when
it tries to find the closing tag, because it is searching from the beginning of the tag, it finds the closing tag of the parametered tag. This causes
strange things to happen.

This has been fixed by forcing the parsing system to start searching for the closing tag after the position where the starting tag is.
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/bbcode.php10
1 files changed, 6 insertions, 4 deletions
diff --git a/includes/bbcode.php b/includes/bbcode.php index e4b3d7f..40533a3 100755 --- a/includes/bbcode.php +++ b/includes/bbcode.php
@@ -68,8 +68,9 @@ class BBCode
68 while (strpos($to_parse, '[' . $name . ']') !== FALSE) 68 while (strpos($to_parse, '[' . $name . ']') !== FALSE)
69 { 69 {
70 $bbcode_uid = unique_id(); 70 $bbcode_uid = unique_id();
71 $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . ']', strpos($to_parse, '[' . $name . ']'), strlen($name) + 2); 71 $bbpos = strpos($to_parse, '[' . $name . ']');
72 $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos($to_parse, '[/' . $name . ']'), strlen($name) + 3); 72 $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . ']', $bbpos, strlen($name) + 2);
73 $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3);
73 74
74 $value = str_replace('{CONTENT}', '\1', $value); 75 $value = str_replace('{CONTENT}', '\1', $value);
75 $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse); 76 $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse);
@@ -81,8 +82,9 @@ class BBCode
81 while (strpos($to_parse, '[' . $name . '=') !== FALSE) 82 while (strpos($to_parse, '[' . $name . '=') !== FALSE)
82 { 83 {
83 $bbcode_uid = unique_id(); 84 $bbcode_uid = unique_id();
84 $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . '=', strpos($to_parse, '[' . $name . '='), strlen($name) + 2); 85 $bbpos = strpos($to_parse, '[' . $name . '=');
85 $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos($to_parse, '[/' . $name . ']'), strlen($name) + 3); 86 $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . '=', $bbpos, strlen($name) + 2);
87 $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3);
86 88
87 $value = str_replace('{PARAM}', '\1', $value); 89 $value = str_replace('{PARAM}', '\1', $value);
88 $value = str_replace('{CONTENT}', '\2', $value); 90 $value = str_replace('{CONTENT}', '\2', $value);