From b831c72e78e978c37d9981ab4c805eba05de8a7d Mon Sep 17 00:00:00 2001
From: Alex Barth <alex_b@53995.no-reply.drupal.org>
Date: Tue, 6 Jul 2010 00:47:22 +0000
Subject: [PATCH] #624464 lyricnz, alex_b: Fix to 'support tabs as delimiters'.

---
 CHANGELOG.txt                            | 1 +
 feeds_defaults/tests/feeds_defaults.test | 2 +-
 plugins/FeedsCSVParser.inc               | 7 ++++---
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index d0a56429..f4490dd3 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -3,6 +3,7 @@
 Feeds 6.x 1.X XXXX
 ------------------
 
+- #624464 lyricnz, alex_b: Fix to "support tabs as delimiters".
 - #840350 lyricnz: (Optionally) Transliterate enclosure filenames to provide
   protection from awkward names.
 - #842040 dixon_: Accept all responses from the 2xx status code series.
diff --git a/feeds_defaults/tests/feeds_defaults.test b/feeds_defaults/tests/feeds_defaults.test
index 4c65b3b8..5f7aac74 100644
--- a/feeds_defaults/tests/feeds_defaults.test
+++ b/feeds_defaults/tests/feeds_defaults.test
@@ -347,7 +347,7 @@ class FeedsDefaultsNodeTestCase extends FeedsDefaultsTestCase {
     $this->drupalPost('import/node/delete-items', array(), 'Delete');
     $edit = array(
       'files[feeds]' => $this->absolutePath() .'/tests/feeds/nodes.tsv',
-      'feeds[FeedsCSVParser][delimiter]' => "\t",
+      'feeds[FeedsCSVParser][delimiter]' => "TAB",
     );
     $this->drupalPost('import/node', $edit, 'Import');
     $this->assertText('Created 8 Story nodes.');
diff --git a/plugins/FeedsCSVParser.inc b/plugins/FeedsCSVParser.inc
index 730726e8..4d3be593 100644
--- a/plugins/FeedsCSVParser.inc
+++ b/plugins/FeedsCSVParser.inc
@@ -16,7 +16,8 @@ class FeedsCSVParser extends FeedsParser {
     $iterator = new ParserCSVIterator(realpath($batch->getFilePath()));
     $source_config = $source->getConfigFor($this);
     $parser = new ParserCSV();
-    $parser->setDelimiter($source_config['delimiter']);
+    $delimiter = $source_config['delimiter'] == 'TAB' ? "\t" : $source_config['delimiter'];
+    $parser->setDelimiter($delimiter);
     $parser->setSkipFirstLine(FALSE);
     $rows = $parser->parse($iterator);
     unset($parser);
@@ -89,7 +90,7 @@ class FeedsCSVParser extends FeedsParser {
       '#options'  => array(
         ',' => ',',
         ';' => ';',
-        "\t" => 'TAB',
+        'TAB' => 'TAB',
       ),
       '#default_value' => isset($source_config['delimiter']) ? $source_config['delimiter'] : ',',
     );
@@ -115,7 +116,7 @@ class FeedsCSVParser extends FeedsParser {
       '#options' => array(
         ',' => ',',
         ';' => ';',
-        "\t" => 'TAB',
+        'TAB' => 'TAB',
       ),
       '#default_value' => $this->config['delimiter'],
     );
-- 
GitLab