This is an edge-case problem but none-the-less one that we ran into recently.

If you have a string that contains escaped single quotes, those single quotes become un-escaped upon import.

For example, create a new story node with the following body:

A story with \' \" \\

Then import it at admin/content/node. The resulting body is now:

A story with ' \" \

So as you can see, we loose the "escaping" on single quotes and backslashes. It's not really escaping within the node body of course, but we have had unintentional data modification.

This patch replaces the use of addslashes() with strtr() and only escapes the only character that matters: a single quote. It also makes it so we don't have to do any string correction on import at all, which is a nice bonus.

CommentFileSizeAuthor
node_export_slashes.patch748 bytesquicksketch
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

danielb’s picture

Status: Needs review » Fixed

Thank you.

quicksketch’s picture

Shoot, sorry there were two typos in that comment:

// Escape single quotes so we dont' accidently exit the string.

Should be:

// Escape single quotes so we don't accidentally exit the string.
danielb’s picture

kk
Committed

quicksketch’s picture

Thanks, danielb! Much appreciated.

Status: Fixed » Closed (fixed)

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

safetypin’s picture

Version: 6.x-2.x-dev » 6.x-2.23
Component: Node Export » Node export
Status: Closed (fixed) » Active

I just performed exports and imports and have found that double quotes are still being escaped in export, and not unescaped on import. I was exporting/importing the data as a file download/upload. Does that make a difference?

danielb’s picture

I don't know what to do about this then. It's worked for me no matter how it was implemented. Could be magic quotes or some garbage?

danielb’s picture

Version: 6.x-2.23 » 6.x-2.x-dev
Status: Active » Closed (fixed)

Sorry, I can't replicate double quotes being escaped in a file download. This issue was fixed, if you can find out more info about your situation, especially how to replicate it, please start a new issue. It is possible the problem you're having has to do with PHP configuration? I'm not really sure.