Skip to content

CMB2 strips too many slashes #981

@leewillis77

Description

@leewillis77

Expected Behavior:

Data is saved, and retrieved as entered

Actual Behavior:

If the following data is entered into a text field:

[{"content":"This is a \"some\" content"}]

What will be saved, and retrieved out of the database when accessed is:

[{"content":"This is a "some" content"}]

Note that slashes have been over-zealously removed. The data should be retrieved as-is without modification.

Steps to reproduce (I have confirmed I can reproduce this issue on the trunk branch):

  1. Register a standard text field, e.g. as per the example.
$cmb_demo->add_field( array(
	'name'       => esc_html__( 'Test Text', 'cmb2' ),
	'desc'       => esc_html__( 'field description (optional)', 'cmb2' ),
	'id'         => $prefix . 'text',
	'type'       => 'text',
) );
  1. Enter the following into the field:

[{"content":"This is a \"some\" content"}]

  1. Save the entity. Note that what gets stored, and retrieved is:

[{"content":"This is a "some" content"}]

instead of

[{"content":"This is a \"some\" content"}]

Note: While I've reported this as an issue with the "text" type, the original bug I observed was with a custom field, within a repeatable group, so any fix probably needs to be generic across all field types, not just text.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions