thunderer / Shortcode

Advanced shortcode (BBCode) parser and engine for PHP

Home Page:http://kowalczyk.cc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling self-closing shortcode without handler

thunderer opened this issue · comments

In the current implementation of Processor, TextSerializer is used to serialize shortcodes without registered handler. This may cause bugs when for example text contains consecutive shortcodes of the same name. Let's say that we have text with two shortcodes, one self-closed and one with content: [code /] [code]content[/code] and it does not have a registered handler. The result of the processing will be: [code] [code]content[/code] because said serializer does not have the information about shortcode being self-closing or not. Then if this text gets passed again into Processor the result will be a single shortcode with content [code]content. Possible solutions to this problem:

  • force self-closing slash on all shortcodes without content (content equal to null),
  • expand RegexParser to also extract information about that "slash" and ParsedShortcode to store it as a separate field.

Handling self-closing shortcodes has been reworked, now Processor is aware of the shortcode text fragments offsets and replaces them with greater granularity and TextSerializer checks also for shortcode being ParsedShortcodeInterface and getting closing marker offset from it.