[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.6-23-ge150432
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Oct 23 04:17:17 EDT 2009
The branch, 3.8-trunk has been updated
via e150432be7c5a6bd7b6bad8820f773b4e6e0d6e4 (commit)
from 37683bce2e2b5e5d72a68f5cc6767435556958e5 (commit)
Summary of changes:
lib/RT/Interface/Web.pm | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
- Log -----------------------------------------------------------------
commit e150432be7c5a6bd7b6bad8820f773b4e6e0d6e4
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Oct 23 16:17:05 2009 +0800
refactor StripContent: make it return empty string as long as the content does *not* have any *real* data, i.e. \S but without <br/> and
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 549d24c..07f3358 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -595,37 +595,48 @@ sub SendStaticFile {
sub StripContent {
my %args = @_;
my $content = $args{Content};
- my $html = ( ( $args{ContentType} || '' ) eq "text/html" );
+ return '' unless $content;
+
+ # Make the content have no 'weird' newlines in it
+ $content =~ s/\r+\n/\n/g;
+
+ my $return_content = $content;
+
+ my $html = $args{ContentType} && $args{ContentType} eq "text/html";
my $sigonly = $args{StripSignature};
# Save us from undef warnings
return '' unless defined $content;
- # Make the content have no 'weird' newlines in it
- $content =~ s/\r+\n/\n/g;
+ # massage content to easily detect if there's any real content
+ $content =~ s/\s+//g; # yes! remove all the spaces
+ if ( $html ) {
+ # remove html version of spaces and newlines
+ $content =~ s! !!g;
+ $content =~ s!<br/?>!!g;
+ }
# Filter empty content when type is text/html
- return '' if $html && $content =~ m{^\s*(?:<br[^>]*/?>)*\s*$}s;
+ return '' if $html && $content !~ /\S/;
# If we aren't supposed to strip the sig, just bail now.
- return $content unless $sigonly;
+ return $return_content unless $sigonly;
# Find the signature
my $sig = $args{'CurrentUser'}->UserObj->Signature || '';
- $sig =~ s/^\s+//;
- $sig =~ s/\s+$//;
+ $sig =~ s/\s+//g;
# Check for plaintext sig
- return '' if not $html and $content =~ /^\s*(--)?\s*\Q$sig\E\s*$/;
+ return '' if not $html and $content =~ /^(--)?\Q$sig\E$/;
# Check for html-formatted sig
RT::Interface::Web::EscapeUTF8( \$sig );
return ''
- if $html
- and $content =~ m{^\s*(?:<p>)?\s*(--)?\s*<br[^>]*?/?>\s*\Q$sig\E\s*(?:</p>)?\s*$}s;
+ if $html
+ and $content =~ m{^(?:<p>)?(--)?\Q$sig\E(?:</p>)?$}s;
# Pass it through
- return $content;
+ return $return_content;
}
sub DecodeARGS {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list