From d0f9e936b2d34e349ce5c0e20d6b9d7c8f7d0239 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 3 Dec 2010 20:51:46 +0000 Subject: [PATCH] protect against empty control fields (bad MARC) git-svn-id: svn://svn.open-ils.org/ILS/trunk@18915 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/MARC/Record.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Open-ILS/web/js/dojo/MARC/Record.js b/Open-ILS/web/js/dojo/MARC/Record.js index 247379844f..1f2e51aabb 100644 --- a/Open-ILS/web/js/dojo/MARC/Record.js +++ b/Open-ILS/web/js/dojo/MARC/Record.js @@ -201,8 +201,8 @@ if(!dojo._hasResource["MARC.Record"]) { var f_node = doc.createElementNS( 'http://www.loc.gov/MARC21/slim', element ); f_node.setAttribute('tag', f.tag); - if (f.isControlfield() && f.data) { - dojox.xml.parser.textContent(f_node, f.data); + if (f.isControlfield()) { + if (f.data) dojox.xml.parser.textContent(f_node, f.data); } else { f_node.setAttribute('ind1', f.indicator(1)); f_node.setAttribute('ind2', f.indicator(2)); @@ -227,8 +227,8 @@ if(!dojo._hasResource["MARC.Record"]) { fromBreaker : function (marctxt) { var me = this; - function cf_line_data (l) { return l.substring(4) }; - function df_line_data (l) { return l.substring(6) }; + function cf_line_data (l) { return l.substring(4) || '' }; + function df_line_data (l) { return l.substring(6) || '' }; function line_tag (l) { return l.substring(0,3) }; function df_ind1 (l) { return l.substring(4,5).replace('\\',' ') }; function df_ind2 (l) { return l.substring(5,6).replace('\\',' ') }; @@ -285,8 +285,9 @@ if(!dojo._hasResource["MARC.Record"]) { var mtxt = '=LDR ' + this.leader + '\n'; mtxt += dojo.map( this.fields, function (f) { - if (f.isControlfield() && f.data) { - return '=' + f.tag + ' ' + f.data.replace(' ','\\','g'); + if (f.isControlfield()) { + if (f.data) return '=' + f.tag + ' ' + f.data.replace(' ','\\','g'); + return '=' + f.tag; } else { return '=' + f.tag + ' ' + f.indicator(1).replace(' ','\\') + -- 2.11.0