Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BBCode shortcode parameter value chokes on the tag closing character #65

Open
MrPetovan opened this issue Feb 25, 2018 · 4 comments
Open
Assignees
Labels

Comments

@MrPetovan
Copy link

Using CommonSyntax, the following text won't be picked up by the regular parser:
[url=http://example.com]link[/url]

The parser correctly recognize the opening shortcode, continue to getting the parameter value, then finds a /which is a marker token, then look for a closing token, doesn't find it and return false.

Using parameter delimiter like this [url="http://example.com"]link[/url] yields the expected result.

@MrPetovan MrPetovan changed the title BBCode shortcode chokes on the tag closing character BBCode shortcode parameter value chokes on the tag closing character Feb 25, 2018
@thunderer thunderer self-assigned this Feb 25, 2018
@thunderer thunderer added the bug label Feb 25, 2018
@thunderer
Copy link
Owner

@MrPetovan Your reasoning here and in #38 is correct, the RegularParser::value() method matches only "strings", ie. "not tokens" as parameter values. Mentioned URL contains shortcode token "closing mark", ie. forward slash /. Parameter value delimiters " will indeed solve the issue, but I think the generic whitespace delimited value should be possible. I'm working on the solution.

@MrPetovan
Copy link
Author

For backward compatibility in my project, I need to be able to parse such shortcode.

I see two ways of solving it:

  • Check that there’s a close token just after the marker token, or else keep on parsing the parameter value.
  • Check that there’s a marker token just before a close token to decide it’s a self-closing tag.

Just throwing ideas around.

@thunderer
Copy link
Owner

@MrPetovan please look at #66. Please install the dev- composer version from the PR branch and verify that it works for your test cases. I added a quite thorough test for it, but I suspect there may be some uncovered edge cases. Let me know if all my answers so far and this PR solves all your issues. I'm always happy to answer more questions.

Flyers won their match, I had fun writing code, and it's nearly dawn at my place, so I'm going to a well-deserved sleep. :)

@rhukster
Copy link

rhukster commented Apr 3, 2019

I use a little workaround for wordpress parser:

    public function getBbCode($sc)
    {
        $code = null;

        if ($this->getParser() === 'wordpress') {
            $params = $sc->getParameters();
            if (is_array($params)) {
                $keys = array_keys($params);
                $code = trim(array_shift($keys), '=');
            }
        } else {
            $code = $sc->getBbCode();
        }
        return $code;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants