[open-ils-commits] [GIT] Evergreen ILS branch rel_2_0 updated. 1f9c2177643d50e4bd9065d850bbe2e17fe7b271

Evergreen Git git at git.evergreen-ils.org
Mon Nov 14 09:58:29 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, rel_2_0 has been updated
       via  1f9c2177643d50e4bd9065d850bbe2e17fe7b271 (commit)
      from  8f6b118477f5ea745b374aa6904718c9001bd509 (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 1f9c2177643d50e4bd9065d850bbe2e17fe7b271
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/OpenILS/Application/Trigger/Reactor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
index 4c94a3d..a427c48 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Trigger/Reactor.pm
@@ -7,6 +7,7 @@ use DateTime::Format::ISO8601;
 use Unicode::Normalize;
 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';
@@ -153,6 +154,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
@@ -164,14 +175,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:
 .../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