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

More forgiving parser generating valid HTML #10

Open
eazrael opened this issue Feb 9, 2019 · 2 comments
Open

More forgiving parser generating valid HTML #10

eazrael opened this issue Feb 9, 2019 · 2 comments
Assignees
Labels

Comments

@eazrael
Copy link

eazrael commented Feb 9, 2019

Currently I am parsing existing BBCode and you can find every possible errors. The output is this cases is not well-formed html. Any chance to get a more forgiving parser in the future?

`[img]http://cdn.edgecast.steamstatic.com/steamcommunity/public/images/clans/28666429/702d6d88139eb439facae57989a9c6633784c519.png

[/img]
`
In this example, there's a new line (needed two to make github make a visible line break :( ) before the closing tag. The generated HTML looks like this:

<img src="http://cdn.edgecast.steamstatic.com/steamcommunity/public/images/clans/28666429/702d6d88139eb439facae57989a9c6633784c519.png<br/> " />

and does not pass verification (nor HTMLPurifier). due to the
in the unclosed src attribute.

Then there is this code:
[url]http://store.steampowered.com/app/759750[url]
The closing slash was omitted. The result is:
<a href="http://store.steampowered.com/app/759750">http://store.steampowered.com/app/759750">store.steampowered.com/app/759750<a href="</a></a> /

The request is to make the HTML output standard compliant while including as much of the input as possible.

@chriskonnertz
Copy link
Owner

chriskonnertz commented Feb 19, 2019

Hello,

long story told short: The current implemenation (v1.x) has some flaws by design. It was my intention to make this parser forgiving, but that's not a simple task. Already tried to rewrite it ( => https://github.com/chriskonnertz/bbcode/tree/2.0-dev ) but this is a challenging and time intensive task.

Quite frankly, I can try to fix this specific issue but I am sure you will find other problems where incorrect BBCode leads to incorrect HTML code. In my opinion it is a) impossible to avoid all of these problems or b) possible but not worth the effort with BBCode having lost most of its relevance (hi @ Markdown).

So yeah, I will try to find a solution for this specific bug but to fix all of this kind I'd have to complete v2. But I have no idea if/when this is going to happen.

@eazrael
Copy link
Author

eazrael commented Feb 20, 2019

No problem, it's your time :-) Anything that can reduce erroronous output is surely a plus. Everybody makes errors and non-programmers are probably more prone to make these errors.

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

2 participants