Jump to content

BB-codes prevention


Numbered
 Share

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

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy