Skip to content

Commit 027691b

Browse files
committed
Bring up to date with 2.x changes
1 parent 1e8457c commit 027691b

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

BBCodePlus/BBCodePlus.php

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function register() {
2121
$this->name = plugin_lang_get( 'title' );
2222
$this->description = plugin_lang_get( 'description' );
2323
$this->page = 'config';
24-
$this->version = '1.3.9';
24+
$this->version = '1.3.14';
2525

2626
$this->requires['MantisCore'] = '1.3.0';
2727
# this plugin can coexist with MantisCoreFormatting.
@@ -193,15 +193,14 @@ public function rss( $p_event, $p_string ) {
193193
* @return string Formatted text
194194
*/
195195
public function email( $p_event, $p_string ) {
196-
#$p_string = string_strip_hrefs( $p_string );
197-
#$p_string = string_process_bug_link( $p_string, FALSE );
198-
#$p_string = string_process_bugnote_link( $p_string, FALSE );
199-
#$p_string = $this->string_process_cvs_link( $p_string, FALSE );
200196

201-
if ( ON == plugin_config_get( 'process_email' ) )
197+
if ( ON == plugin_config_get( 'process_email' ) ) {
198+
# process content to make sure all tags are converted to BBCode.
202199
$p_string = $this->string_process_bbcode( $p_string );
203-
else
200+
}
201+
# strip the BBCode right back out. mantisbt email does not currently support HTML.
204202
$p_string = $this->string_strip_bbcode( $p_string );
203+
205204
return $p_string;
206205
}
207206
//-------------------------------------------------------------------
@@ -250,12 +249,12 @@ function add_tags() {
250249
$this->t_bbCode->addParser('table-body', '/\[tbody\](.*?)\[\/tbody\]/s', '<tbody>$1</tbody>', '$1');
251250
$this->t_bbCode->addParser('table-head-data', '/\[th\](.*?)\[\/th\]/s', '<th>$1</th>', '$1');
252251
$this->t_bbCode->addParser('code', '/\[code\](.*?)\[\/code\]/s', '<pre class="bbcodeplus pre"><code class="bbcodeplus code language-none">$1</code></pre>', '$1');
253-
$this->t_bbCode->addParser('code-lang', '/\[code=(\w+)\](.*?)\[\/code\]/s', '<pre class="bbcodeplus pre"><code class="bbcodeplus code language-$1">$2</code></pre>','$2');
252+
$this->t_bbCode->addParser('code-lang', '/\[code=(\w*)\](.*?)\[\/code\]/s', '<pre class="bbcodeplus pre"><code class="bbcodeplus code language-$1">$2</code></pre>','$2');
254253
$this->t_bbCode->addParser('code-ln', '/\[code start=([0-9]+)\](.*?)\[\/code\]/s', '<pre class="bbcodeplus pre line-numbers" data-start="$1"><code class="language-none">$2</code></pre>', '$3');
255-
$this->t_bbCode->addParser('code-lang-ln', '/\[code=(\w+)\ start=([0-9]+)\](.*?)\[\/code\]/s',
254+
$this->t_bbCode->addParser('code-lang-ln', '/\[code=(\w*)\ start=([0-9]+)\](.*?)\[\/code\]/s',
256255
'<pre class="bbcodeplus pre line-numbers" data-start="$2"><code class="bbcodeplus code language-$1">$3</code></pre>', '$3');
257256
$this->t_bbCode->addParser('quote', '/\[quote\](.*?)\[\/quote\]/s', '<blockquote class="bbcodeplus blockquote">$1</blockquote>', '$1');
258-
$this->t_bbCode->addParser('named-quote', '/\[quote=(\w+)\](.*?)\[\/quote\]/s',
257+
$this->t_bbCode->addParser('named-quote', '/\[quote=([\s\w,\'\.@-]*)\](.*?)\[\/quote\]/su',
259258
'<blockquote class="bbcodeplus blockquote"><p class="mb-0">$2</p><footer class="bbcodeblus blockquote-footer"><cite title="$1">$1</cite></footer></blockquote>',
260259
'$1 wrote: $2');
261260
}
@@ -277,9 +276,8 @@ function string_process_bbcode( $p_string, $p_multiline = TRUE ) {
277276
}
278277

279278
# convert url-strings into links
280-
$p_string = preg_replace( "/^((http|https|ftp|file):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#\|]+)/i", "[url]$1[/url]", $p_string );
281-
$p_string = preg_replace( "/([^='\"(\[url\]|\[img\])])((http|https|ftp|file):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#\|]+)/i", "$1[url]$2[/url]", $p_string );
282-
279+
$p_string = preg_replace( "/^((https?|s?ftp|file|irc[6s]?|ssh|telnet|nntp|git|svn(?:\+ssh)?|cvs|mailto):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#\|]+)/i", "[url]$1[/url]", $p_string );
280+
$p_string = preg_replace( "/([^='\"(\[url\]|\[img\])])((https?|s?ftp|file|irc[6s]?|ssh|telnet|nntp|git|svn(?:\+ssh)?|cvs|mailto):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#\|]+)/i", "$1[url]$2[/url]", $p_string );
283281

284282
# if mantis core formatting plugin process text feature is off, we need to sanitize the html,
285283
# for safety. this is the only functionality we will support when the MantisCoreFormatting plugin is

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@ If you would like to contribute to BBCode plus, please [read this guide first](h
2525

2626
## Change Log
2727

28+
### 1.3.14
29+
30+
- Corrected email parsing behavior when Email Processing is turned on. MantisBT does not support HTML email natively.
31+
32+
### 1.3.13
33+
34+
- Added the following characters to work with the quotee's name in the named quote function (basically to support email-adresses here): . @ - [@FSD-Christian-ISS](https://github.com/FSD-Christian-ISS)
35+
36+
### 1.3.12
37+
38+
- Fixed display of quotes when quotee's name contains unicode characters, commas or single quotes [@FSD-Christian-ISS](https://github.com/FSD-Christian-ISS)
39+
40+
### 1.3.11
41+
42+
- Fixed issue with additional protocols in link insertion.
43+
44+
### 1.3.10
45+
46+
- Fixed rendering issue of code blocks when language parameter was left empty
47+
- Fixed rendering issue of quote blocks when quotee parameter contained whitespaces
48+
2849
### 1.3.9
2950

3051
- Fixed display issue of loose links (thanks to [@FSD-Christian-ISS](https://github.com/FSD-Christian-ISS) )

0 commit comments

Comments
 (0)