[open-ils-commits] r18915 - trunk/Open-ILS/web/js/dojo/MARC (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Dec 3 15:51:51 EST 2010
Author: miker
Date: 2010-12-03 15:51:46 -0500 (Fri, 03 Dec 2010)
New Revision: 18915
Modified:
trunk/Open-ILS/web/js/dojo/MARC/Record.js
Log:
protect against empty control fields (bad MARC)
Modified: trunk/Open-ILS/web/js/dojo/MARC/Record.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/MARC/Record.js 2010-12-03 19:51:22 UTC (rev 18914)
+++ trunk/Open-ILS/web/js/dojo/MARC/Record.js 2010-12-03 20:51:46 UTC (rev 18915)
@@ -201,8 +201,8 @@
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 @@
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 @@
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(' ','\\') +
More information about the open-ils-commits
mailing list