johannheyne / advanced-custom-fields-table-field

Advanced Custom Fields: Table Field
15 stars 4 forks source link

Character Escaping Issue (Double Quotes) #3

Closed tess0072 closed 5 years ago

tess0072 commented 7 years ago

We have observed an issue with the plugin not working properly when duplicating WooCommerce products. To reproduce the issue, create a table field group and associate it to your WooCommerce Product post type. When duplicating the WooCommerce Product you will see that the table field group generates a JSON parse error.

I have narrowed the issue down to the double-quotes character (") if the table data contains double quotes it will not duplicate properly (JSON Parse Error). I am sure this issue could manifest itself in other ways but this is the precise issue we are experiencing.

Could you please advise if you can replicate the issue and also if you are planning on fixing it.

johannheyne commented 7 years ago

Yes, I can replicate that issue. I think, this issue happens because WooCommerce may uses the WordPress function update_metadata() while duplicating a product. update_metadata() applies wp_unslash(). wp_unslash() removes the slashes of the preserved double-quotes characters of JSON content strings. For example {"key":"citation:\"Hello World!\""} ends up {"key":"citation:"Hello World!""} That kills the JSON string. That was an issue on ACF itself on restoring posts from a revision. The fix is very easy by using wp_slash() before update_metadata(). I will contact WooCommerce about this. I can´t do anything else.

johannheyne commented 7 years ago

I submitted a ticket to WooCommerce.

tess0072 commented 7 years ago

Thank you for looking into this.

johannheyne commented 7 years ago

I´ve got the advise from the WooCommerce customer support to submit that issue at the WooCommerce Github repository:

https://github.com/woocommerce/woocommerce/issues/15808

johannheyne commented 7 years ago

The issue will be fixed in WooCommerce version 3.1.0.