fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-10-24 10:10 am

[dw-free] Binary data not displaying properly in propedit, will be wiped out if you try to save any

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

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

Use textarea rather than a textbox for binary data, and then make the
textarea uneditable.

Patch by [personal profile] fu.

Files modified:
  • htdocs/admin/propedit.bml
--------------------------------------------------------------------------------
diff -r c5449359fa0e -r a59e5f1a8804 htdocs/admin/propedit.bml
--- a/htdocs/admin/propedit.bml	Mon Oct 24 18:04:10 2011 +0800
+++ b/htdocs/admin/propedit.bml	Mon Oct 24 18:10:37 2011 +0800
@@ -91,7 +91,20 @@
         while ( my $p = $sth->fetchrow_hashref ) {
             my $extra = "<br /><small>$p->{des}</small>";
             my $value = $u->raw_prop( $p->{name} );
-            $value = "<br />" . LJ::html_text({ name => $p->{name}, value => $value, maxlength => '255', size => '100' }) if $can_save;
+
+            if ( $can_save ) {
+                if ( $p->{des} =~ /Storable hashref/ ) {
+                    # prevent this from being resaved via this form
+                    # non-ASCII characters can prevent the value from showing up properly in the input textbox
+                    # which would have caused the data to be wiped out when this form is used
+                    $value = "<br />" . LJ::html_textarea({ value => $value, disabled => 1, cols => 75 } );
+                } else {
+                    $value = "<br />" . LJ::html_text({ name => $p->{name}, value => $value, maxlength => '255', size => '100' })
+                }
+            } else {
+                $value = LJ::ehtml( $value );
+            }
+
             $ret .= "<li><strong>$p->{name}</strong>: $value$extra</li><br />";
         }
         $ret .= "</ul>";
--------------------------------------------------------------------------------