Jump to content

Is there a reason you double up on htmlPurifier in parser?


Flitterkill

Recommended Posts

SNIP

/* Clean HTML */
		if ( $value and $this->htmlPurifier )
		{
			$value = $this->htmlPurifier->purify( $value );
		}
		
/* BBCode, Profanity, etc. */
		if ( $value )
		{
			$value = $this->_parseContent( $value );
		}
						
/* Clean HTML */
		if ( $value and $this->htmlPurifier )
		{
			$value = $this->htmlPurifier->purify( $value );
		}
 
SNIP

Am I missing something or is this just a mistake? Seems inefficient... 4.1.13.2

Link to comment
Share on other sites

Indeed, just taking a quick look at the code you posted this below would be more efficient:

SNIP
		
        /* BBCode, Profanity, etc. */
        if ( $value )
        {
                $value = $this->_parseContent( $value );

                /* Clean HTML */
                if ( $value and $this->htmlPurifier )
                {
                	$value = $this->htmlPurifier->purify( $value );
                }
        }
 
SNIP

 

But I have not looked at the whole class/method the code is from so there might be a reason. Or it's just a copy/paste mistake, they moved it after bbcode parsing and they forgot to delete the one before.

Link to comment
Share on other sites

  • 2 months later...

It's because we use DomDocument, so we have to have well formed HTML to start with. HTMLPurifier does this, so we parse once which removes "bad" stuff and ensures everything is well formed, then we loop through nodes using DomDocument to do whatever bbcode-style processing is needed, and then we run HTML Purifier one more time to be safe (since bbcode replacements could introduce something bad).

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.
×
×
  • Create New...