fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-14 03:33 pm

[dw-free] New icon browser chokes on icon keywords and alt text that look like numbers

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

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

Force alt text to be wrapped in quotes when converted to a JSON string.

Patch by [personal profile] fu.

Files modified:
  • htdocs/tools/endpoints/getuserpics.bml
--------------------------------------------------------------------------------
diff -r d4998fe56980 -r e677ef46248f htdocs/tools/endpoints/getuserpics.bml
--- a/htdocs/tools/endpoints/getuserpics.bml	Wed Dec 14 21:43:02 2011 +0800
+++ b/htdocs/tools/endpoints/getuserpics.bml	Wed Dec 14 23:33:30 2011 +0800
@@ -43,7 +43,11 @@
             state => $upic->state,
             width => $upic->width,
             height => $upic->height,
-            alt => LJ::ehtml($upic->alttext),
+
+            # FIXME: update to a simple . "" conversion when we have a newer JSON version
+            #        ( no code ref will be required )
+            alt => sub { LJ::ehtml($upic->alttext)  . "" }, # force to string
+
             comment => LJ::strip_html($upic->comment),
             id => $id,
             keywords => [ map { LJ::strip_html($_) } $upic->keywords],
@@ -53,6 +57,7 @@
     $upics{ids} = [sort { $a <=> $b } keys %{$upics{pics}}];
     sleep 1 if $LJ::IS_DEV_SERVER;
 
+    local $JSON::ExecCoderef = 1;
     return JSON::objToJson(\%upics);
 }
 _code?>
--------------------------------------------------------------------------------