Fork me on GitHub
Subscribe 6

Ticket #445 (fixed bug)

Can't use [code] string inside a code tag

  • Created: 2011-05-24 10:33:44
  • Reported by: daris
  • Assigned to: FSX
  • Milestone: 1.4.6
  • Component: parser
  • Priority: normal

Try to add a post containing include/parser.php file content inside code tag and you'll see an error smile (it is not doable)

The following errors need to be corrected before the message can be posted:
There is a problem with your [ code] tags
There is a problem with your [ code] tags
There is a problem with your [ code] tags

Argh! I can't post also this error here as it shows same error tongue (added space before code)

History

taylorchu 2011-05-25 01:06:10

    $num_tokens = count($tokens);
    for ($i = 1; $i < $num_tokens; ++$i)
    {
        $temp = explode($end, $tokens[$i]);

        if (count($temp) != 2)//here is the problem!
        {
            $errors[] = $lang_common['BBCode code problem'];
            return array(null, array($text));
        }
        $inside[] = $temp[0];
        $outside[] = $temp[1];
    }

Reines 2011-05-25 17:32:02

  • Milestone set to 1.4.6.

Reines 2011-06-05 19:59:14

  • Owner set to Reines.

Reines 2011-06-05 21:30:13

Commit 7441fc0 to fluxbb fluxbb-1.4

Fixing splitting of code tags, I think! Needs more testing! #445

Reines 2011-06-05 21:32:11

  • Status changed from open to fixed.

I think fixed, please can someone do some testing of this, as it totally rewrites for code tags are split.

PS. We really need some unit tests!

daris 2011-06-06 05:09:49

For my previous comment: regex should have s modifier at the end smile

Reines 2011-06-06 09:00:11

Commit e255e3a to fluxbb fluxbb-1.4

Fixing regex used in split_text, spotted by daris. #445

Franz 2011-06-11 15:30:22

And another (long) post that breaks the code tags: http://fluxbb.org/forums/viewtopic.php?pid=41477#p41477

Franz 2011-06-11 17:45:11

  • Status changed from fixed to open.

Reines 2011-06-12 11:23:57

Ah - this is down to the exceeding pcre.backtrack-limit - as we are using an ungreedy regex. I'll try see what ridgerunner suggests here.

ridgerunner 2011-06-28 15:38:05

As I've said in the past, the basic design of current parser (from 1.3) is less than ideal. There is no simple regex modification that can repair the way CODE is handled.

My new parser allows nested CODE elements - only the outermost element is processed. However, it does not allow an orphaned open or close CODE tag to appear inside the CODE contents.

There is no simple way to unambiguously handle something like:

{code} stuff {code} stuff {/code}
or...
{code} stuff {/code} stuff {/code}

FSX 2011-07-07 20:37:55

I also need this working so I can correctly make the content of a post of topic email friendly.

This is what I've come up with: http://bit.ly/qvh1fC

FSX 2011-07-08 10:31:12

Here is some updated code: http://bit.ly/q5q21p

I can't really figure out how the BBcode checker works. That's the part that's now allowing nested code blocks.

Franz 2011-07-31 21:20:36

  • Owner changed from Reines to FSX.

Based on IRC talk, you should do that now. tongue

FSX 2011-08-06 11:24:33

  • Status changed from open to worksforme.

You can now nest code tags, but these tags must be balanced.

Unbalanced sets are near impossible to get right as ridgerunner says.

With something like Markdown it would be easier.

FSX 2011-08-06 11:25:02

  • Status changed from worksforme to fixed.