diff --git a/precise_bbcode/bbcode/defaults/tag.py b/precise_bbcode/bbcode/defaults/tag.py index ca202c7..ce5e052 100644 --- a/precise_bbcode/bbcode/defaults/tag.py +++ b/precise_bbcode/bbcode/defaults/tag.py @@ -105,7 +105,7 @@ class Options: def render(self, value, option=None, parent=None): href = option if option else value - if href[0] == href[-1] and href[0] in ('"', '\'') and len(href) > 2: + if len(href) > 2 and href[0] == href[-1] and href[0] in ('"', '\''): # URLs can be encapsulated in quotes (either single or double) that aren't part of the # URL. If that's the case, strip them out. href = href[1:-1] diff --git a/tests/unit/test_parser.py b/tests/unit/test_parser.py index c9fd2ac..8d5706e 100644 --- a/tests/unit/test_parser.py +++ b/tests/unit/test_parser.py @@ -116,6 +116,8 @@ class TestParser(object): ('[color=some words]test[/color]', '[color=some words]test[/color]'), # Unknown BBCodes ('[unknown][hello][/unknown]', '[unknown][hello][/unknown]'), + ('[url]"[url]', '[url]"[url]'), + ('[url="]wow, that is very short[url]', '[url="]wow, that is very short[url]'), ) CUSTOM_TAGS_RENDERING_TESTS = {