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

Doesn't work with URL has quote? #78

Open
dzpt opened this issue Sep 1, 2017 · 3 comments
Open

Doesn't work with URL has quote? #78

dzpt opened this issue Sep 1, 2017 · 3 comments

Comments

@dzpt
Copy link

dzpt commented Sep 1, 2017

It works with url bbcode like : [url=http://google.com]abc[/url]
But failed to work with [url='http://google.com']abc[/url]

@Art4
Copy link
Contributor

Art4 commented Sep 1, 2017

Yes, because 'http://google.com' isn't a valid url.

You can build a custom InputValidator based on the internal one that removes the ' characters.

Then create a new url definition and add it to the parser:

$urlValidator = new \My\Own\UrlValidator();
/* [url] link tag */
$builder = new \JBBCode\CodeDefinitionBuilder('url', '<a href="{param}">{param}</a>');
$builder->setParseContent(false)->setBodyValidator($urlValidator);

// Place the CodeDefinition into the parser
$parser->addCodeDefinition($builder->build());

@dzpt
Copy link
Author

dzpt commented Sep 1, 2017

I've tried your way but didn't work.
Actually, it recognize 'http://google.com' as URL, then the link becomes http://domain.com/'http://google.com' , validation rules doesn't help to strip quote and return correct value? 'http://google.com' -> http://google.com

@Art4
Copy link
Contributor

Art4 commented Sep 1, 2017

validation rules doesn't help to strip quote and return correct value?

Sorry, you are right. You have to build a custom CodeDefinition

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

No branches or pull requests

2 participants