[open-ils-commits] [GIT] Evergreen ILS branch master updated. 13bad8097a693995089e08c9bc4352445dec1929

Evergreen Git git at git.evergreen-ils.org
Mon Nov 14 09:57:26 EST 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  13bad8097a693995089e08c9bc4352445dec1929 (commit)
      from  65e7211b4298f65d0b628d834996a4669098ecdc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 13bad8097a693995089e08c9bc4352445dec1929
Author: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
Date:   Tue Oct 11 11:25:51 2011 -0400

    More filtering of characters that could end up in PO JEDI template output
    
    Backslashes cause problems too.  Let's JSON encode this thing and get it
    right once and for all.
    
    Signed-off-by: Lebbeous Fogle-Weekley <lebbeous at esilibrary.com>
    Signed-off-by: Ben Shum <bshum at biblio.org>
    Signed-off-by: Bill Erickson <berick at esilibrary.com>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
index 5f07972..14a69e7 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Trigger/Reactor.pm
@@ -8,6 +8,7 @@ use Unicode::Normalize;
 use XML::LibXML;
 use OpenSRF::Utils qw/:datetime/;
 use OpenSRF::Utils::Logger qw(:logger);
+use OpenSRF::Utils::JSON;
 use OpenILS::Application::AppUtils;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
 my $U = 'OpenILS::Application::AppUtils';
@@ -154,6 +155,16 @@ my $_TT_helpers = {
     get_li_attr => \&get_li_attr,
 
     get_li_attr_jedi => sub {
+        # This helper has to mangle data in at least three interesting ways.
+        #
+        # 1) We'll be receiving data that may already have some \-escaped
+        # characters.
+        #
+        # 2) We need our output to be valid JSON.
+        #
+        # 3) We need our output to yield valid and unproblematic EDI when
+        # passed through edi4r by the edi_pusher.pl script.
+
         my $value = get_li_attr(@_);
         if ($value) {
             # Here we can add any number of special case transformations to
@@ -165,14 +176,24 @@ my $_TT_helpers = {
                 chop $value;
             }
 
-            # Make sure any double quotation marks are escaped.
-            $value =~ s/"/\\"/g;
+            # Typical vendors dealing with EDIFACT would seem not to want
+            # any unicode characters, so trash them. Yes, they're already
+            # in the data escaped like this at this point even though we
+            # haven't JSON-escaped things yet.
+            $value =~ s/\\u[0-9a-f]{4}//g;
 
             # What the heck, get rid of [ ] too (although I couldn't get them
-            # to cause any problems for me.
+            # to cause any problems for me, problems have been reported. See
+            # LP #812593).
             $value =~ s/[\[\]]//g;
         }
 
+        $value = OpenSRF::Utils::JSON->perl2JSON($value);
+
+        # Existing action/trigger templates expect an unquoted string.
+        $value =~ s/^"//g;
+        chop $value;
+
         return $value;
     },
 
diff --git a/Open-ILS/src/support-scripts/edi_pusher.pl b/Open-ILS/src/support-scripts/edi_pusher.pl
index ea9d63e..80e4e19 100755
--- a/Open-ILS/src/support-scripts/edi_pusher.pl
+++ b/Open-ILS/src/support-scripts/edi_pusher.pl
@@ -155,13 +155,7 @@ foreach my $def (@$defs) {
             printf STDERR "ERROR: No edi_default account found for $logstr.  File will not be sent!\n";
         }
 
-        my $jedi = $event->template_output()->data;
-
-        # Crucial identifiers won't contain unicode characters, and EDIFACT
-        # (or at least our translator) generally can't handle them anyway.
-        $jedi =~ s/\\u[0-9a-f]{4}//g;
-
-        $message->jedi($jedi);
+        $message->jedi($event->template_output()->data);
 
         print "\ntarget->provider->edi_default->id: ", $target->provider->edi_default->id, "\n";
         my $logstr2 = sprintf "event %s, PO %s, template_output %s", $_->{id}, $message->purchase_order, $event->template_output->id;

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

Summary of changes:
 .../lib/OpenILS/Application/Trigger/Reactor.pm     |   27 +++++++++++++++++--
 Open-ILS/src/support-scripts/edi_pusher.pl         |    8 +-----
 2 files changed, 25 insertions(+), 10 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list