From 12f4c66c68725c8b269c9e4a59e88622e27f3214 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Delaune?= <stephane.delaune@biblibre.com>
Date: Mon, 12 May 2014 16:58:14 +0200
Subject: [PATCH] [SIGNED-oFF] Bug 12229: fix to prevent adding of invalid
 records in marc file

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described. No errors

Test:
1. Edit record, add 100.000 chars text to 500a
2. xml export produce the record,
3. mrc export do not produce the record,
warning on log
export.pl: record (number 2025) length 102668 is larger than the MARC spec allows (99999 bytes) at...
---
 tools/export.pl |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/export.pl b/tools/export.pl
index 9bbed0b..1a055b0 100755
--- a/tools/export.pl
+++ b/tools/export.pl
@@ -394,6 +394,11 @@ if ( $op eq "export" ) {
                     print "\n";
                 }
                 else {
+                    my (@result_build_tag) = MARC::File::USMARC::_build_tag_directory($record);
+                    if ($result_build_tag[2] > 99999) {
+                        warn "record (number $recordid) length ".$result_build_tag[2]." is larger than the MARC spec allows (99999 bytes)";
+                        next;
+                    }
                     print $record->as_usmarc();
                 }
             }
-- 
1.7.9.5