Potentially broken man tag

It's a custom bb-code. Translation of the [man]...[/man] is a fairly basic conversion to some HTML with a URL. It looks like the {text} you're supposed to use doesn't do any encoding. So it screws up with this one.

 
Maybe we could insert a small bit of inline javascipt that'll encode {text} when it generates the URL. I know encodeURI() could be used here. But I'm a little hesitant to add that.
 
Took me some testing to really understand the issue ... xenforo is working fine, the issue is that the text is used as a query parameter, so would need extra encoding there ... sorry for the noise 🙈
 
Preview looks good but the URL is translated to https://man.freebsd.org/cgi/man.cgi?query=a++&sektion=1&manpath=freebsd-release-ports. The + gets translated to a space, so it looks up the man page for "a", not "a++". That's the crux of the problem.

The [man=foo]bar[/man] uses {option}="foo" and {text}="bar". This gets translated to https://man.freebsd.org/cgi/man.cgi?query={text}&sektion={option}&manpath=freebsd-release-ports. Both the {text} and {option} are used verbatim, no encoding is done on them.
 
I have strong "feelings" against trying to "fix" this the duct-tape-way (javascript) though ... can't you use a PHP-block in these "custom BBcodes" and just add an urlencode() around {text} there?

edit: reading the manual linked answered that:
A PHP callback may be used for more complex replacements that involve running PHP code to work out what the output HTML should be. This is more of a developer option. If this is used, the callback should be specified using the Class and Method fields provided below.

So, that's the way to go here to do it correctly. I'd happily try to help if wanted (although it's been years I touched PHP, but I'd still be confident 😉)
 
No, I don't think I can add PHP code, there's a different option to use a "PHP Callback" but that requires a class to be called that will do the 'translation' of the custom bb-code. I'm not even sure I can inline javascript here. It specifically says "HTML replacement" suggesting it has to be "pure" HTML.
 
Back
Top