[Rt-commit] rt branch, 4.0/ckeditor-escaping, created. rt-4.0.18rc1-11-g0790474

Alex Vandiver alexmv at bestpractical.com
Wed Oct 9 10:30:37 EDT 2013


The branch, 4.0/ckeditor-escaping has been created
        at  079047443f623285cf9efb7550b54f599f9604d5 (commit)

- Log -----------------------------------------------------------------
commit 079047443f623285cf9efb7550b54f599f9604d5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Jan 25 21:47:28 2011 -0500

    Make empty-message-detection happen client-side for CKeditor

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index eda7dde..c040aaa 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1080,39 +1080,24 @@ sub StripContent {
 
     my $return_content = $content;
 
-    my $html = $args{ContentType} && $args{ContentType} eq "text/html";
-    my $sigonly = $args{StripSignature};
+    # If we aren't supposed to strip the sig, just bail now.
+    return $return_content unless $args{StripSignature};
 
-    # 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;
+    # Sig-stripping is done client-side with HTML
+    if ($args{ContentType} && $args{ContentType} eq "text/html") {
+        return "" unless $content =~ /\S/;
+        return $return_content;
     }
 
-    # Filter empty content when type is text/html
-    return '' if $html && $content !~ /\S/;
-
-    # If we aren't supposed to strip the sig, just bail now.
-    return $return_content unless $sigonly;
+    # massage content to easily detect if there's any real content
+    $content =~ s/\s+//g; # yes! remove all the spaces
 
     # Find the signature
     my $sig = $args{'CurrentUser'}->UserObj->Signature || '';
     $sig =~ s/\s+//g;
 
     # Check for plaintext sig
-    return '' if not $html and $content =~ /^(--)?\Q$sig\E$/;
-
-    # Check for html-formatted sig; we don't use EscapeUTF8 here
-    # because we want to precisely match the escapting that FCKEditor
-    # uses.
-    $sig =~ s/&/&/g;
-    $sig =~ s/</</g;
-    $sig =~ s/>/>/g;
-    $sig =~ s/"/"/g;
-    $sig =~ s/'/'/g;
-    return '' if $html and $content =~ m{^(?:<p>)?(--)?\Q$sig\E(?:</p>)?$}s;
+    return '' if $content =~ /^(--)?\Q$sig\E$/;
 
     # Pass it through
     return $return_content;
diff --git a/share/html/NoAuth/js/util.js b/share/html/NoAuth/js/util.js
index a403d2e..afba63d 100644
--- a/share/html/NoAuth/js/util.js
+++ b/share/html/NoAuth/js/util.js
@@ -295,9 +295,15 @@ function ReplaceAllTextareas() {
             // Set the type
             type.val("text/html");
 
-            CKEDITOR.replace(textArea.name,{width:'100%',height:<% RT->Config->Get('MessageBoxRichTextHeight') |n,j%>});
+            var editor = CKEDITOR.replace(textArea.name,{width:'100%',height:<% RT->Config->Get('MessageBoxRichTextHeight') |n,j%>});
             CKEDITOR.basePath = <%RT->Config->Get('WebPath')|n,j%>+"/NoAuth/RichText/";
 
+            // When submitting, clear it out if they didn't change it from the initial sig
+            jQuery(textArea).closest('form').submit(function(){
+                if ( !editor.checkDirty() )
+                    editor.setData('');
+            });
+
             jQuery("#" + textArea.name + "___Frame").addClass("richtext-editor");
         }
     }

-----------------------------------------------------------------------


More information about the Rt-commit mailing list