During Step 3 of an import, if you set a "Text delimiter" and then set "Escape character" to "none", the import doesn't recognize the end of a text-delimited field.

For example, this

%title%|%description%
%Book%|%Book description goes here...%

parses as

title%|%description%|%Book%|%Book description goes here...%

This is because of

$pos_td = strpos($buffer, $td, $start);
$pos_ec = strpos($buffer, $ec . $td, $start);

if ($pos_td !== FALSE && ($pos_ec === FALSE || $pos_td <= ($pos_ec - strlen($td)))) {

in node_import_read_from_file() of node_import.inc.

If $ec is set to "none" then $td===$ec.$td therefore $pos_td===$pos_ec which fails the ($pos_ec === FALSE) condition.

I fixed it by changing the condition to this

if ($pos_td !== FALSE && ($td === $ec.$td || $pos_ec === FALSE || $pos_td <= ($pos_ec - strlen($td)))) {

to handle that case.

Sorry, I would submit a patch if I knew how.

Comments

Robrecht Jacques’s picture

Status: Active » Fixed

Fixed in -dev. Will be included in -rc5.

I have fixed it by doing:

$pos_ec = strlen($ec) > 0 ? strpos($buffer, $ec . $td, $start) : FALSE;

which says there is no escaped delimiter when the escape character is empty.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.