XF 2.2 Pushing HTML to a post via API?

Dannymh

Active member
Hi all,

Just wondering if there is a way to push a message into the Post API endpoint that has HTML in it, and that HTML is rendered on the end rather than displayed as text?

Trying to build a header into it which is limited when using the table bbcode so was hoping I could put it in the message and have it render?
At the moment I have tried pushing it in with html_entity_decode and htmlentities but just ends up as text in the message.

I know its probably a long shot, but I was hoping it could go in somewhat like the "Message parsed" response and be rendered, but it appears this may not be possible.

Cheers
Daniel
 
At the end of the day, the message is stored as BB Code in the database, and any remaining HTML (however it got there), will be escaped and displayed as plain text, when next rendered from BB Code to HTML. If you're trying to have a custom HTML element that is not yet supported by BB Codes, try setting up a custom BB Code that fulfills your needs first.
 
I've been tring this with post thread and I can get bold text to work using BB, but not line breaks. I've tried inserting

Code:
<br> [br] [/br] and \\ too

For bold text

Code:
[b] and [/b]

work fine. Would love to be able to get linebreaks in there though if anyone can help.
 
If that's the case then your newline characters are being escaped. I've just tested and it works as expected.
 
If you want to display full html in posts, you can patch the following, at your own risk :cool:

src\XF\Str\Formatter.php replaceSmiliesHtml() line 225

Code:
return $this->replaceSmiliesInText($text, $replace, 'htmlspecialchars');

Replace
Code:
'htmlspecialchars'
with
Code:
null

You can package this as an add-on for it to survive XF upgrades.

Once again, this is at your own risk, the html is escaped by default for a reason (security among others).
 
Back
Top Bottom