jbowens / jBBCode

A lightweight but extensible BBCode parser
http://jbbcode.com
MIT License
164 stars 32 forks source link

Content inside invalid-tag not parsing #36

Open nokimaro opened 9 years ago

nokimaro commented 9 years ago

Code definition from example to [color] with OptionValidator

$builder = new CodeDefinitionBuilder('color', '<span style="color: {option}">{param}</span>');
$builder->setUseOption(true)->setOptionValidator($CssColorValidator);

Here is text with invalid option in [color]

[b] bold text
  [color=!nvaL!d_color]
    [u] must be underline[/u]
  [/color]
[/b]

Result is

<b> bold text
[color=!nvaL!d_color] [u] must be underline [/u] [/color]
</b>
nokimaro commented 9 years ago

I think if setParseContent() is true and we have only OptionValidator then we must parse content ({param}) even if option invalid. Or it's unsafe?

Kubo2 commented 9 years ago

@nokimaro No, it isn't. Invalid node should be let as-is, and the content "inside" it (which isn't really inside it, beacuse the node should be removed from the AST/DOM when it is invalid) should be normally parsed. That's the thing, the content "inside" invalid node isn't really a child node, because there's no (valid) parent node.