go-search-replace icon indicating copy to clipboard operation
go-search-replace copied to clipboard

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

Open sjinks opened this issue 3 years ago • 2 comments

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

sjinks avatar Dec 10 '22 21:12 sjinks

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.

nickchomey avatar Sep 11 '24 03:09 nickchomey

Yes, see github.com/Automattic/go-search-replace/issues/36#issuecomment-3348959380

kkmuffme avatar Sep 29 '25 20:09 kkmuffme