helios-ag / FMBbCodeBundle

:capital_abcd: BBCode bundle for Symfony projects
Other
57 stars 35 forks source link

[url] bbcode requires quotes to be filtered #95

Closed dave128 closed 9 years ago

dave128 commented 9 years ago

It seems that the URL filter requires the bbcode to use quotes to mark it as a URL correctly.

For example:

[url=www.google.com]www.google.com[/url] - does not work [url="www.google.com"]www.google.com[/url] - works!

Per all bbcode standards I have seen, the url bbcode does not require quotations.

http://www.bbcode.org/examples/?id=9

Is there a way to use the more standard url bbcode syntax or am I doing something wrong?

EDIT: The reason I need this is that I am doing a forum migration from an old platform to symfony and all of the old post use the non-quoted url bbcode.

Thanks!

helios-ag commented 9 years ago

Hi @dave128, disable "strict" option, that requires double quotes for attributes

fm_bbcode:
  filter_sets:
    my_default_filter:
      strict: false #
dave128 commented 9 years ago

Ah okay I swear I tried that before and it didn't work. I didn't have the best test case though because many of the links I am migrating use the [b] tag inside the url which causes the text to be bolded but doesn't apply the link.

Ex: [url=www.google.com][b]Google[/b][/url] Ex: [b][url=www.google.com]Google[/url][/b]

Both bbcodes return just the bold text.

Should that be supported or is there any other setting that needs to be added to support a nested bbcode?

EDIT: I also wanted to note that both implementations of [b] listed above work when quotes are around the link url.

Thank you for the quick response I really appreciate it!

helios-ag commented 9 years ago

Thats a strange behavior, here is mine config for bundle:

fm_bbcode:
  filter_sets:
    my_default_filter:
      strict: false # if you want to parse attr values without quotes
      locale: en
      xhtml: false
      filters: [ default, block, code, email, image, list, url ]

and test string:

    {{'[url=www.google.ru]Google[/url]
    [url=www.google.com][b]Google[/b][/url]
    [b][url=www.google.com]Google[/url][/b]
'|bbcode_filter('my_default_filter') }}

which returns the following:

<a href="http://www.google.ru">Google</a><br>    <a href="http://www.google.com"><b>Google</b></a><br>    <b><a href="http://www.google.com">Google</a></b>
dave128 commented 9 years ago

Okay I figured out where my issue was. Totally my fault like as suspected XD. I didn't realize there was a filter called 'forum_filter' defined in the vendor code and when I was trying to apply my own filter with that same name and I didn't have the custom configuration properly loaded so my filter was just using the default - which is why my "strict: false" was not reflected properly.

Thank you so much for taking the time to respond and help me debug my issue by providing a test case!

helios-ag commented 9 years ago

Glad to help!