Automattic / go-search-replace

🚀 Search & replace URLs in WordPress SQL files.
https://wpvip.com/2018/03/28/data-sync-on-vip-go/
GNU General Public License v3.0
88 stars 19 forks source link

Replace does not work for serialized data if the string does not end with a new line #35

Open sjinks opened 1 year ago

sjinks commented 1 year ago

To reproduce:

php -r 'echo serialize("aaaaabbbbbbbbbbaaaaa");' > test.txt
cat test.txt | ./go-search-replace bbbbbbbbbb ccccc

Expected result:

s:15:"aaaaacccccaaaaa";

Actual result: empty output

nickchomey commented 2 months ago

I see the problem. It is because the regex that is used s:\d+:\\\".*?\\\"; expects a \ before the quotation marks, such as s:15:\"aaaaacccccaaaaa\";

Browsing a sample WP database, \" seems to be the standard delimiter - I cant find a single instance of s:##:". They all have s:##:\"

I suggest closing this issue (though there are other valid open issues and efforts related to serialize length.