fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-06-09 05:16 pm

[dw-free] Unicode line separator in an entry causes dynamic cut expander to fail

[commit: http://hg.dwscoalition.org/dw-free/rev/fa561230eac7]

http://bugs.dwscoalition.org/show_bug.cgi?id=2685

Avoids an error that causes an alert popup when expanding cuts with certain
text.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/DW/Controller/CutExpander.pm
--------------------------------------------------------------------------------
diff -r 982f34c834a0 -r fa561230eac7 cgi-bin/DW/Controller/CutExpander.pm
--- a/cgi-bin/DW/Controller/CutExpander.pm	Wed Jun 09 17:15:14 2010 +0000
+++ b/cgi-bin/DW/Controller/CutExpander.pm	Thu Jun 10 01:22:12 2010 +0800
@@ -58,6 +58,10 @@ sub cutexpander_handler {
         # make sure the user can read the entry
         if ( $entry->visible_to( $remote ) ) {
             my $text = load_cuttext( $entry, $remote, $args->{cutid} );
+            # FIXME: temporary fix.
+            # remove some unicode characters that could cause the returned JSON to break
+            # like in LJ::ejs, but we don't need to escape quotes, etc (objToJson does that)
+            $text =~ s/\xE2\x80[\xA8\xA9]//gs;
             $r->print( objToJson( { text => $text } ) );
             return $r->OK;
         }
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org