Jump to content

BB-codes prevention


Numbered

Recommended Posts

Hello, guys! Could anyone (maybe IPS) help with BB codes prevention? I want to post some content which said to press the "B" button. Our content managers like to put "[" and "]" around "b". But it transforms into nothing and makes all next text bold. Same for "s" (stroke, yep) and "i" (italic).
I tried to use HTML-editor and wrote [s] But unfortunately, it transforms into [ and ] and then stroke again!
Any ideas (without hooks, obviously)?

Link to comment
Share on other sites

4 minutes ago, bfarber said:

There is no built in capability to accomplish this realistically. You can probably create a custom editor widget for this.

Edit: We have an editor plugin that is designed to emulate an inline code block but it isn't functional here.

I see. Thanks for the answer! So, the best way (for now) not escape the plugin+hook creation.


For other members who will come here for the same question:
We need to create a hook for \IPS\Helpers\Form\Editor for the method _getParser(). There we just need to redefine default parser calling with false in first param. So the default

/**
 * Get parser object
 *
 * @return	\IPS\Text\Parser
 */
protected function _getParser()
{
    return new \IPS\Text\Parser( TRUE, ( $this->options['attachIds'] === NULL ? md5( $this->options['autoSaveKey'] ) : $this->options['attachIds'] ), NULL, "{$this->options['app']}_{$this->options['key']}", !$this->bypassFilterProfanity(), !$this->canUseHtml(), method_exists( $this->extension, 'htmlPurifierConfig' ) ? array( $this->extension, 'htmlPurifierConfig' ) : NULL );
}

will transform to

/**
 * Get parser object
 *
 * @return	\IPS\Text\Parser
 */
protected function _getParser()
{
    return new \IPS\Text\Parser( FALSE, ( $this->options['attachIds'] === NULL ? md5( $this->options['autoSaveKey'] ) : $this->options['attachIds'] ), NULL, "{$this->options['app']}_{$this->options['key']}", !$this->bypassFilterProfanity(), !$this->canUseHtml(), method_exists( $this->extension, 'htmlPurifierConfig' ) ? array( $this->extension, 'htmlPurifierConfig' ) : NULL );
}

Complete Plugin with hook: Disable BB Codes.xml

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...