deliciousbrains / better-search-replace

A simple plugin for updating URLs or other text in a database.
https://bettersearchreplace.com
GNU General Public License v3.0
86 stars 36 forks source link

Serialization with expected backslashes break #53

Open sybrew opened 5 years ago

sybrew commented 5 years ago

When we pass this data to WordPress' Post Meta system:

[ 'item' => '\\' ]

We get this:

a:1:{s:4:"item";s:1:"\";}

Serialized data should be treated as-is; it's why we use serialization over JSON in the first place. Method mysql_escape_mimic() double-escapes these strings.

When passing the serialized metadata, we get this:

a:1:{s:4:\"item\";s:1:\"\\\";}

With that, the string is now broken, and unserializing it would return (bool) false.