jbowens / jBBCode

A lightweight but extensible BBCode parser
http://jbbcode.com
MIT License
164 stars 32 forks source link

[url] tag does not work when URL does not have a schema prefixed #40

Open ghost opened 9 years ago

ghost commented 9 years ago

When using the DefaultCodeDefinitionSet the following does not work: [url=www.google.com]www.google.com[/url]. This is not unreasonable since it is technically not a valid URL, however most users will expect this to work. It may be fruitful to include a mechanism where it can default to the http:// schema when none is found.

This issue has been raised on behalf of https://github.com/r04r/Minichan/issues/21.

23W commented 9 years ago

Same error with img tag. UrlValidator is very strong, it works with filter_var($input, FILTER_VALIDATE_URL) and do not pass relative URLs and URLs without scheme. May be parse_url() is better way for URL validation.

ghost commented 9 years ago

I have some code here to deal with this, but it's pretty hacky: https://github.com/r04r/Minichan/commit/0d2853443216d42df808a8d6d622930db38595ab