Skip to content
Snippets Groups Projects
Commit 433d7377 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add ability to trip tags on-request

Cleanup and make HTML safe by default
Strip empty lines in TEXT content
parent 09b41861
No related branches found
No related tags found
No related merge requests found
...@@ -1131,7 +1131,7 @@ class Note extends ThreadEntry { ...@@ -1131,7 +1131,7 @@ class Note extends ThreadEntry {
class ThreadBody /* extends SplString */ { class ThreadBody /* extends SplString */ {
private static $types = array('text', 'html'); static $types = array('text', 'html');
var $body; var $body;
var $type; var $type;
...@@ -1140,7 +1140,7 @@ class ThreadBody /* extends SplString */ { ...@@ -1140,7 +1140,7 @@ class ThreadBody /* extends SplString */ {
$type = strtolower($type); $type = strtolower($type);
if (!in_array($type, static::$types)) if (!in_array($type, static::$types))
throw new Exception($type.': Unsupported ThreadBody type'); throw new Exception($type.': Unsupported ThreadBody type');
$this->body = $text; $this->body = (string) $body;
$this->type = $type; $this->type = $type;
} }
...@@ -1154,10 +1154,21 @@ class ThreadBody /* extends SplString */ { ...@@ -1154,10 +1154,21 @@ class ThreadBody /* extends SplString */ {
return new ThreadBody(sprintf('<pre>%s</pre>', return new ThreadBody(sprintf('<pre>%s</pre>',
Format::htmlchars($this->body)), $type); Format::htmlchars($this->body)), $type);
case 'html:text': case 'html:text':
return new ThreadBody(Format::html2text($this->body), $type); return new ThreadBody(Format::html2text((string) $this), $type);
} }
} }
function stripQuotedReply($tag) {
//Strip quoted reply...on emailed messages
if (!$tag || strpos($this->body, $tag) === false)
return;
if ((list($msg) = explode($tag, $this->body, 2)) && trim($msg))
$this->body = $msg;
}
function __toString() { function __toString() {
return $this->body; return $this->body;
} }
...@@ -1165,12 +1176,13 @@ class ThreadBody /* extends SplString */ { ...@@ -1165,12 +1176,13 @@ class ThreadBody /* extends SplString */ {
class TextThreadBody extends ThreadBody { class TextThreadBody extends ThreadBody {
function __construct($body) { function __construct($body) {
parent::__construct($body, 'text'); parent::__construct(Format::stripEmptyLines($body), 'text');
} }
} }
class HtmlThreadBody extends ThreadBody { class HtmlThreadBody extends ThreadBody {
function __construct($body) { function __construct($body) {
parent::__contruct($body, 'html'); $body = trim($body, " <>br/\t\n\r") ? Format::safe_html($body) : '';
parent::__construct($body, 'html');
} }
} }
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment