Skip to content

Commit

Permalink
Corrected issues with stripping BBCode when processing is turned off …
Browse files Browse the repository at this point in the history
…(was adding unwanted <br> elements).

Corrected issues with detecting formatter feature states.
  • Loading branch information
bkraul committed Feb 17, 2016
1 parent 78c3c05 commit 4e620b1
Showing 1 changed file with 10 additions and 27 deletions.
37 changes: 10 additions & 27 deletions BBCodePlus/BBCodePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function register() {
$this->name = plugin_lang_get( 'title' );
$this->description = plugin_lang_get( 'description' );
$this->page = 'config';
$this->version = '1.0.9';
$this->version = '1.0.10';

$this->requires['MantisCore'] = '1.2.0';
# require jQuery.
Expand Down Expand Up @@ -209,21 +209,21 @@ function string_process_bbcode( $p_string, $p_multiline = TRUE ) {
$p_string = $this->restore_pre_code_tags( $p_string, $p_multiline );

# remove breaks from [code] added by mantis formatting.
if ( $this->t_MantisCoreFormatting_process_text ) {
if ( ON == $this->t_MantisCoreFormatting_process_text ) {
$p_string = $this->string_code_nl2br($p_string);
$p_string = $this->string_list_nl2br($p_string);
} else {
$p_string = string_html_specialchars( $p_string );
$p_string = string_restore_valid_html_tags( $p_string, true );
}

# process bug and note links (if not already addressed.)
if ( !$this->t_MantisCoreFormatting_process_buglinks ) {
if ( OFF == $this->t_MantisCoreFormatting_process_buglinks ) {
$p_string = string_process_bug_link( $p_string, TRUE );
$p_string = string_process_bugnote_link( $p_string, TRUE );
}

if ( !$this->t_MantisCoreFormatting_process_vcslinks ) {
if ( OFF == $this->t_MantisCoreFormatting_process_vcslinks ) {
$p_string = $this->string_process_cvs_link( $p_string );
}

Expand Down Expand Up @@ -319,12 +319,11 @@ function string_process_bbcode( $p_string, $p_multiline = TRUE ) {
')
, $p_string);


# process quotes.
$p_string = $this->string_process_quote($p_string);

# add line breaks except for code blocks (only if core formatting is OFF);
if ( !$this->t_MantisCoreFormatting_process_text ) {
if ( OFF == $this->t_MantisCoreFormatting_process_text ) {
$p_string = string_nl2br($p_string);
}

Expand All @@ -346,20 +345,10 @@ function string_strip_bbcode( $p_string, $p_multiline = TRUE ) {
$t_change_quotes = TRUE;
ini_set( 'magic_quotes_sybase', FALSE );
}

# restore pre/code tags.
$p_string = $this->restore_pre_code_tags( $p_string, $p_multiline);

# process bug and note links (if not already addressed.)
if ( !$this->t_MantisCoreFormatting_process_buglinks ) {
$p_string = string_process_bug_link( $p_string, TRUE );
$p_string = string_process_bugnote_link( $p_string, TRUE );
}

if ( !$this->t_MantisCoreFormatting_process_vcslinks ) {
$p_string = $this->string_process_cvs_link( $p_string );
}

# ensures that the links will be opened in a new window/tab, so as to not lose the currently displayed issue.
$t_extra_link_tags = 'target="_blank"';

Expand Down Expand Up @@ -437,7 +426,7 @@ function string_strip_bbcode( $p_string, $p_multiline = TRUE ) {

# perform the actual replacement.
$p_string = preg_replace( $t_search, $t_replace, $p_string );

# code=lang
$p_string = preg_replace_callback('/\[code=(\w+)\](.+)\[\/code\]/imsU',
create_function('$m', '
Expand All @@ -452,19 +441,13 @@ function string_strip_bbcode( $p_string, $p_multiline = TRUE ) {
')
, $p_string);


# process quotes.
$p_string = $this->string_strip_quote($p_string);

# add line breaks except for code blocks (only if core formatting is OFF);
if ( !$this->t_MantisCoreFormatting_process_text ) {
$p_string = string_nl2br($p_string);
}

if ( $t_change_quotes )
ini_set( 'magic_quotes_sybase', TRUE );
return $p_string;

return $p_string;
}
//-------------------------------------------------------------------
/**
Expand Down

0 comments on commit 4e620b1

Please sign in to comment.