Title: [Plugin: CSV Importer] Escaping quotation marks / serialized array
Last modified: August 19, 2016

---

# [Plugin: CSV Importer] Escaping quotation marks / serialized array

 *  Resolved [maorb](https://wordpress.org/support/users/maorb/)
 * (@maorb)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-csv-importer-escaping-quotation-marks/)
 * Hi,
 * I wrote a script which parses html DOM and outputs one csv file for all html 
   pages needed to be imported.
    Everything works fine, except issue I encounter
   with quotation marks. I looked at the example.csv fle and didn’t manage how should
   I escape them.
 * The problematic field I’ve got is a serialized array that should be saves as 
   a custom field. It holds values for several input fields.
    The serialized array
   is being crreated via the **serialize($arr);**, and as you know it has a lot 
   of quotation marks inside.
 * When I look in the my csv file, I see the seiralized array something like this:
   **
   a:6:{s:10:””_video_wmv””;s:11:””cookegg.wvx””;s:7:””YouTube””;s:15:””www.youtube.
   com””;s:8:””Facebook””;s:10:””www.fb.com””;s:4:””Flix””;s:12:””www.flix.com””;
   s:8:””duration””;s:0:””””;s:15:””shorter_excerpt””;s:0:””””;}”**
 * But when I look in the database, I see it like this –
    **s:196:”a:6:{s:10:”_video_wmv”;
   s:11:”cookegg.wvx”;s:7:”YouTube”;s:15:”www.youtube.com”;s:8:”Facebook”;s:10:”
   www.fb.com”;s:4:”Flix”;s:12:”www.flix.com”;s:8:”duration”;s:0:””;s:15:”shorter_excerpt”;
   s:0:””;}”;**
 * meaning, a **s:196:”** has been added to the beginning of it, and a **“;** added
   to the end.
    This causes the WP not to interpret the data as needed to the appropriate
   fields.
 * I don’t even know if is an issue of escaping quotation marks, rather than have
   the serialized array be saved in the db as it is, without adding it these prefix
   and suffix.
 * Any idea how can I deal with that?
 * Many thanks,
    Maor
 * [http://wordpress.org/extend/plugins/csv-importer/](http://wordpress.org/extend/plugins/csv-importer/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [maorb](https://wordpress.org/support/users/maorb/)
 * (@maorb)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-csv-importer-escaping-quotation-marks/#post-1924674)
 * Ok, I found what is causing the problem, and this is bug in WordPress.
 * You use the **add_post_meta()** to create the custom field. This function uses
   the **add_metadata()** function, whic uses the **maybe_serialize()** function.
   
   Well, the maybe_srialize() function should check if there is need to serialize
   or not, and perform serialization according that. But, it appears that the **
   maybe_serialize()** function **always ** serialize and not only if needed.
 * You can see it on wp-includes/functions.php, line 1005.
 * This is why if you pass a serialized array/object it is serializing it again,
   and thus the prefix of the s:196 is appending.
 * When I changed the core function maybe_serialize(), it all went ok!
 * I’ve submited a ticket on the trac about this, if someone interested in following
   this –
    [http://core.trac.wordpress.org/ticket/16597](http://core.trac.wordpress.org/ticket/16597)

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: CSV Importer] Escaping quotation marks / serialized array’ is
closed to new replies.

 * ![](https://ps.w.org/csv-importer/assets/icon-256x256.png?rev=3039593)
 * [CSV Importer](https://wordpress.org/plugins/csv-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/csv-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/csv-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/csv-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/csv-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/csv-importer/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [maorb](https://wordpress.org/support/users/maorb/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-csv-importer-escaping-quotation-marks/#post-1924674)
 * Status: resolved