Skip to main content
Making code safer
Source Link
Matthew Boynes
  • 7.1k
  • 2
  • 23
  • 36

I would wage that your issue is with \r\n (CRLF). If the newlines are created in Windows, they'll go into the database as \r\n and when serialized get counted as 2 characters. Then when importing, they'll only be counted as 1 character and they'll corrupt the string. I tested this hypothesis and sure enough I was able to create a corrupt serialized string.

If this is your issue, the solution would be to replace "\r""\r\n" with """\n" when saving the post meta. This is a long shot, but I can't think of what else might cause this behavior. Give 'er a shot and let me know how it works out!

I would wage that your issue is with \r\n (CRLF). If the newlines are created in Windows, they'll go into the database as \r\n and when serialized get counted as 2 characters. Then when importing, they'll only be counted as 1 character and they'll corrupt the string. I tested this hypothesis and sure enough I was able to create a corrupt serialized string.

If this is your issue, the solution would be to replace "\r" with "" when saving the post meta. This is a long shot, but I can't think of what else might cause this behavior. Give 'er a shot and let me know how it works out!

I would wage that your issue is with \r\n (CRLF). If the newlines are created in Windows, they'll go into the database as \r\n and when serialized get counted as 2 characters. Then when importing, they'll only be counted as 1 character and they'll corrupt the string. I tested this hypothesis and sure enough I was able to create a corrupt serialized string.

If this is your issue, the solution would be to replace "\r\n" with "\n" when saving the post meta. This is a long shot, but I can't think of what else might cause this behavior. Give 'er a shot and let me know how it works out!

Source Link
Matthew Boynes
  • 7.1k
  • 2
  • 23
  • 36

I would wage that your issue is with \r\n (CRLF). If the newlines are created in Windows, they'll go into the database as \r\n and when serialized get counted as 2 characters. Then when importing, they'll only be counted as 1 character and they'll corrupt the string. I tested this hypothesis and sure enough I was able to create a corrupt serialized string.

If this is your issue, the solution would be to replace "\r" with "" when saving the post meta. This is a long shot, but I can't think of what else might cause this behavior. Give 'er a shot and let me know how it works out!