fix for embeded $
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 16 Mar 2005 01:59:32 +0000 (01:59 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 16 Mar 2005 01:59:32 +0000 (01:59 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@235 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/JSON.pm

index 0711049..5e4392e 100644 (file)
@@ -83,6 +83,10 @@ sub JSON2perl {
        my $class = shift;
        local $_ = shift;
 
+       s/(?<!\\)\$/\\\$/gmo; # fixup $ for later
+       s/(?<!\\)\@/\\\@/gmo; # fixup @ for later
+       s/(?<!\\)\%/\\\%/gmo; # fixup % for later
+
        # Convert JSON Unicode...
        s/\\u(\d{4})/chr(hex($1))/esog;
 
@@ -122,6 +126,7 @@ sub old_JSON2perl {
 
        $json =~ s/(?<!\\)\$/\\\$/gmo; # fixup $ for later
        $json =~ s/(?<!\\)\@/\\\@/gmo; # fixup @ for later
+       $json =~ s/(?<!\\)\%/\\\%/gmo; # fixup % for later
 
        my @casts;
        my $casting_depth = 0;