[open-ils-commits] [GIT] Evergreen ILS branch rel_2_11 updated. f47d0c59d59bc3b06cd641f78859cc92d5983dab

Evergreen Git git at git.evergreen-ils.org
Sat Mar 11 23:20:25 EST 2017


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_11 has been updated
       via  f47d0c59d59bc3b06cd641f78859cc92d5983dab (commit)
       via  1d3d3af7d02c62f4cc8fde9ca3d8c631d8cca1e0 (commit)
       via  e5671114210c8d089c5e8a2eb888532541149463 (commit)
       via  09a3ae2c1eb904fe03dc41bf71d57fc419bb04b3 (commit)
       via  471807efdf03816b6b22aebf0ff29a0e3e730699 (commit)
       via  2314b4d1df8d07ba6ce176e94e6c25417ce65624 (commit)
      from  9fd3147414130272cefe8c171249f6c4acb36bc7 (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 f47d0c59d59bc3b06cd641f78859cc92d5983dab
Author: Dan Scott <dscott at laurentian.ca>
Date:   Sat Mar 11 23:05:15 2017 -0500

    LP#1442276: Stamp schema upgrade for corrupted XSL output
    
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql
index 9adc72b..a719054 100644
--- a/Open-ILS/src/sql/Pg/002.schema.config.sql
+++ b/Open-ILS/src/sql/Pg/002.schema.config.sql
@@ -91,7 +91,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1018', :eg_version); -- csharp/Dyrcona/gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1030', :eg_version); -- dbs/kmlussier
 
 CREATE TABLE config.bib_source (
 	id		SERIAL	PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix b/Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql
similarity index 95%
rename from Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix
rename to Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql
index 9557c4f..a3e37b5 100644
--- a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix
+++ b/Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql
@@ -1,6 +1,6 @@
 BEGIN;
 
---SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version);
+SELECT evergreen.upgrade_deps_block_check('1030', :eg_version);
 
 CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT AS $func$
   use strict;

commit 1d3d3af7d02c62f4cc8fde9ca3d8c631d8cca1e0
Author: Kathy Lussier <klussier at masslnc.org>
Date:   Fri Mar 10 22:53:18 2017 -0500

    LP#1442276: Upgrade script for Encoding UTF8 output
    
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>
    Signed-off-by: Dan Scott <dscott at laurentian.ca>

diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix b/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix
new file mode 100644
index 0000000..9557c4f
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix
@@ -0,0 +1,43 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version);
+
+CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT AS $func$
+  use strict;
+
+  use XML::LibXSLT;
+  use XML::LibXML;
+
+  my $doc = shift;
+  my $xslt = shift;
+
+  # The following approach uses the older XML::LibXML 1.69 / XML::LibXSLT 1.68
+  # methods of parsing XML documents and stylesheets, in the hopes of broader
+  # compatibility with distributions
+  my $parser = $_SHARED{'_xslt_process'}{parsers}{xml} || XML::LibXML->new();
+
+  # Cache the XML parser, if we do not already have one
+  $_SHARED{'_xslt_process'}{parsers}{xml} = $parser
+    unless ($_SHARED{'_xslt_process'}{parsers}{xml});
+
+  my $xslt_parser = $_SHARED{'_xslt_process'}{parsers}{xslt} || XML::LibXSLT->new();
+
+  # Cache the XSLT processor, if we do not already have one
+  $_SHARED{'_xslt_process'}{parsers}{xslt} = $xslt_parser
+    unless ($_SHARED{'_xslt_process'}{parsers}{xslt});
+
+  my $stylesheet = $_SHARED{'_xslt_process'}{stylesheets}{$xslt} ||
+    $xslt_parser->parse_stylesheet( $parser->parse_string($xslt) );
+
+  $_SHARED{'_xslt_process'}{stylesheets}{$xslt} = $stylesheet
+    unless ($_SHARED{'_xslt_process'}{stylesheets}{$xslt});
+
+  return $stylesheet->output_as_chars(
+    $stylesheet->transform(
+      $parser->parse_string($doc)
+    )
+  );
+
+$func$ LANGUAGE 'plperlu' STRICT IMMUTABLE;
+
+COMMIT;

commit e5671114210c8d089c5e8a2eb888532541149463
Author: Dan Scott <dscott at laurentian.ca>
Date:   Sun Mar 5 11:45:12 2017 -0500

    LP#1442276 output_as_chars() instead of toString
    
    The SuperCat transform methods for records retrieved by record ID or ISBN call
    toString on the XSLT output object, which results in a byte string and thus
    corrupted output. Instead, call output_as_chars() on the stylesheet object to
    generate a character string and avoid corruption.
    
    Signed-off-by: Dan Scott <dscott at laurentian.ca>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
index 3a8aebe..2715571 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm
@@ -2688,6 +2688,7 @@ sub retrieve_record_transform {
     my $rid = shift;
 
     (my $transform = $self->api_name) =~ s/^.+record\.([^\.]+)\.retrieve$/$1/o;
+    my $xslt = $record_xslt{$transform}{xslt};
 
     my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
     #$_storage->connect;
@@ -2699,7 +2700,7 @@ sub retrieve_record_transform {
 
     return undef unless ($record);
 
-    return $U->entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
+    return $U->entityize($xslt->output_as_chars($xslt->transform($_parser->parse_string($record->marc))));
 }
 
 sub retrieve_isbn_transform {
@@ -2717,12 +2718,13 @@ sub retrieve_isbn_transform {
     return undef unless (@$recs);
 
     (my $transform = $self->api_name) =~ s/^.+isbn\.([^\.]+)\.retrieve$/$1/o;
+    my $xslt = $record_xslt{$transform}{xslt};
 
     my $record = $_storage->request( 'open-ils.cstore.direct.biblio.record_entry.retrieve' => $recs->[0]->record )->gather(1);
 
     return undef unless ($record);
 
-    return $U->entityize($record_xslt{$transform}{xslt}->transform( $_parser->parse_string( $record->marc ) )->toString);
+    return $U->entityize($xslt->output_as_chars($xslt->transform($_parser->parse_string($record->marc))));
 }
 
 sub retrieve_record_objects {

commit 09a3ae2c1eb904fe03dc41bf71d57fc419bb04b3
Author: Dan Scott <dan at coffeecode.net>
Date:   Fri Mar 3 16:03:30 2017 -0500

    LP#1442276 pgTAP test for oils_xslt_process
    
    In moving from the deprecated XML::LibXSLT::output_string() to output_as_chars(),
    add a regression test to ensure that we do not suffer from corrputed encoding
    output in the future.
    
    We test both the case where an output encoding has been explicitly declared,
    as well as the case where an output encoding has not been explicitly declared.
    It was this subtle difference that was causing the problem with output_string().
    
    Signed-off-by: Dan Scott <dan at coffeecode.net>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/t/regress/lp1442276_oils_xslt_encoding.pg b/Open-ILS/src/sql/Pg/t/regress/lp1442276_oils_xslt_encoding.pg
new file mode 100644
index 0000000..628b134
--- /dev/null
+++ b/Open-ILS/src/sql/Pg/t/regress/lp1442276_oils_xslt_encoding.pg
@@ -0,0 +1,45 @@
+BEGIN;
+
+SELECT plan(2);
+
+INSERT INTO biblio.record_entry(id, last_xact_id, marc) VALUES
+(999999999, 'pgtap', '<record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/MARC21/slim http://www.loc.gov/standards/marcxml/schema/MARC21slim.xsd"><leader>01750 am a2200481Ia 4500</leader><controlfield tag="001">2784593</controlfield><controlfield tag="003">CONIFER</controlfield><controlfield tag="005">20121031173514.0</controlfield><controlfield tag="008">121026s2012    ja ac         001 0beng d</controlfield><datafield tag="020" ind1=" " ind2=" "><subfield code="a">2760550060</subfield></datafield><datafield tag="110" ind1="2" ind2=" "><subfield code="a">Association d''économie politique.</subfield></datafield><datafield tag="245" ind1="1" ind2="0"><subfield code="a">Syndicalisme et société</subfield></datafield><datafield tag="260" ind1=" " ind2=" "><subfield code="a">Sillery [Que.] :</subfield><subfield code="b">Presses de l''Université du Québec,</subfield><subfield code="c">1988.</subfield></datafield><datafield tag=
 "300" ind1=" " ind2=" "><subfield code="a">209 p. ;</subfield><subfield code="c">29 cm.</subfield></datafield><datafield tag="650" ind1=" " ind2="0"><subfield code="a">Syndicalism</subfield><subfield code="x">Political aspects</subfield><subfield code="z">Québec (Province)</subfield><subfield code="v">Congresses.</subfield></datafield><datafield tag="901" ind1=" " ind2=" "><subfield code="a">5894462</subfield><subfield code="b">OCoLC</subfield><subfield code="c">2784593</subfield><subfield code="t">biblio</subfield></datafield></record>')
+;
+INSERT INTO config.xml_transform(name, namespace_uri, prefix, xslt) VALUES (
+'testdeclaration', 'http://example.org/testdeclaration', 'testdeclaration', $$<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" xmlns:marc="http://www.loc.gov/MARC21/slim"
+	xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	exclude-result-prefixes="xlink marc" version="1.0">
+	<xsl:output encoding="UTF-8" indent="yes" method="xml"/>
+<xsl:template match="//marc:record">
+	<xsl:for-each select="marc:datafield[@tag='245']/marc:subfield[@code='a']">
+		<title>
+			<xsl:value-of select="text()" />
+		</title>
+	</xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>$$
+),('testnodeclaration', 'http://example.org/testnodeclaration', 'testnodeclaration', 
+$$<xsl:stylesheet xmlns="http://www.loc.gov/mods/v3" xmlns:marc="http://www.loc.gov/MARC21/slim"
+	xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	exclude-result-prefixes="xlink marc" version="1.0">
+	<xsl:output indent="yes" method="xml"/>
+<xsl:template match="//marc:record">
+	<xsl:for-each select="marc:datafield[@tag='245']/marc:subfield[@code='a']">
+		<title>
+			<xsl:value-of select="text()" />
+		</title>
+	</xsl:for-each>
+</xsl:template>
+</xsl:stylesheet>$$
+);
+
+SELECT is(evergreen.oils_xslt_process(bre.marc, cxt.xslt), $$<?xml version="1.0" encoding="UTF-8"?>
+<title xmlns="http://www.loc.gov/mods/v3">Syndicalisme et société</title>
+$$, 'Is our XSLT output corrupted?') FROM biblio.record_entry bre, config.xml_transform cxt WHERE bre.id = 999999999 AND cxt.name = 'testdeclaration';
+
+SELECT is(evergreen.oils_xslt_process(bre.marc, cxt.xslt), $$<?xml version="1.0"?>
+<title xmlns="http://www.loc.gov/mods/v3">Syndicalisme et société</title>
+$$, 'Is our XSLT output corrupted?') FROM biblio.record_entry bre, config.xml_transform cxt WHERE bre.id = 999999999 AND cxt.name = 'testnodeclaration';
+
+ROLLBACK;

commit 471807efdf03816b6b22aebf0ff29a0e3e730699
Author: Dan Scott <dscott at laurentian.ca>
Date:   Fri Mar 3 01:40:19 2017 -0500

    LP#1442276 Prevent corrupted Unicode chars in MARCTXT and RIS
    
    The MARCTXT and RIS feeds use the deprecated XML::LibXSLT::output_string()
    method which, depending on the stylesheet, generated either a byte string
    or characters. Using output_as_bytes() ensures it is always a byte string
    and avoids the resulting MARCTXT and RIS output from corrupting Unicode
    characters.
    
    Signed-off-by: Dan Scott <dscott at laurentian.ca>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat/Feed.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat/Feed.pm
index 2cb401f..56146cb 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat/Feed.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/SuperCat/Feed.pm
@@ -793,7 +793,7 @@ sub toString {
         searchClass => "'$class'",
     );
 
-    return $marctxt_xslt->output_string($new_doc); 
+    return $marctxt_xslt->output_as_bytes($new_doc);
 }
 
 
@@ -845,7 +845,7 @@ sub toString {
         searchClass => "'$class'",
     );
 
-    return $ris_xslt->output_string($new_doc); 
+    return $ris_xslt->output_as_bytes($new_doc);
 }
 
 

commit 2314b4d1df8d07ba6ce176e94e6c25417ce65624
Author: Dan Scott <dscott at laurentian.ca>
Date:   Fri Mar 3 01:26:53 2017 -0500

    LP#1442276 Encode UTF8 output of XSLT transforms
    
    The XML::LibXSLT::output_string() method was deprecated in favour of
    output_as_bytes() and output_as_chars(). The latter always generates
    UTF8 output as characters, which is what we need, while output_string()
    behaviour depended on the stylesheet.
    
    Signed-off-by: Dan Scott <dscott at laurentian.ca>
    Signed-off-by: Kathy Lussier <klussier at masslnc.org>

diff --git a/Open-ILS/src/sql/Pg/002.functions.config.sql b/Open-ILS/src/sql/Pg/002.functions.config.sql
index 77876fe..22324ae 100644
--- a/Open-ILS/src/sql/Pg/002.functions.config.sql
+++ b/Open-ILS/src/sql/Pg/002.functions.config.sql
@@ -91,7 +91,7 @@ CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT
   $_SHARED{'_xslt_process'}{stylesheets}{$xslt} = $stylesheet
     unless ($_SHARED{'_xslt_process'}{stylesheets}{$xslt});
 
-  return $stylesheet->output_string(
+  return $stylesheet->output_as_chars(
     $stylesheet->transform(
       $parser->parse_string($doc)
     )

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

Summary of changes:
 .../perlmods/lib/OpenILS/Application/SuperCat.pm   |    6 ++-
 .../src/perlmods/lib/OpenILS/WWW/SuperCat/Feed.pm  |    4 +-
 Open-ILS/src/sql/Pg/002.functions.config.sql       |    2 +-
 Open-ILS/src/sql/Pg/002.schema.config.sql          |    2 +-
 .../Pg/t/regress/lp1442276_oils_xslt_encoding.pg   |   45 ++++++++++++++++++++
 .../1030.function.oils_xslt_process_utf8_fix.sql   |   43 +++++++++++++++++++
 6 files changed, 96 insertions(+), 6 deletions(-)
 create mode 100644 Open-ILS/src/sql/Pg/t/regress/lp1442276_oils_xslt_encoding.pg
 create mode 100644 Open-ILS/src/sql/Pg/upgrade/1030.function.oils_xslt_process_utf8_fix.sql


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list