dcwatson / bbcode

A pure python bbcode parser and formatter.
BSD 2-Clause "Simplified" License
68 stars 17 forks source link

Quoted option values are cut on square bracket #14

Closed homeworkprod closed 10 years ago

homeworkprod commented 10 years ago

I'd like to enable users to specify the author of a quote. http://bbcode.readthedocs.org/en/latest/formatters.html describes an approach to implement a quote tag formatter that recognizes multiple variants of such a specification. I'm only allow [quote author="John"]…[/quote] in my code.

This fails when the author name contains square brackets, as it is not uncommon on Internet forums (especially in gaming communities):

[quote author="SomeClan][John"]…[/quote]

In this case only SomeClan is recognized as the option value, the first closing square bracket is interpreted as the start tag's closing symbol, and [John"] followed by the text between the quote tags will be the content.

Since the value of the author option is quoted, I expect the parser to honor those quotes and not interpret tag delimiters inside it.

dcwatson commented 10 years ago

This is definitely a bug, but also hits a limitation of the parser as it's currently implemented - I'm checked for the next bracket without scanning anything in between, so the tokenizer has no idea the bracket is inside a quoted option.

I've been meaning to clean up the tokenizer anyway, this will be a good excuse to do so.

dcwatson commented 10 years ago

This isn't the big tokenizer cleanup I eventually want to do, but should fix the issue you're having, with the added bonus of allowing double- or single-quoting tag options. I'll push out a PyPI release shortly.

homeworkprod commented 9 years ago

Thank you very much, v1.0.19 fixes the issue for me.