Skip to content

iAPI: Enforce correct namespaces in all places (directives, functions…) that accept a namespace #63749

@luisherranz

Description

@luisherranz

Description

Namespaces can only contain alphanumeric characters, hyphens, underscores, and forward slashes, but as of today, we're not ensuring that namespaces have the correct format in all places that accept a namespace (directives, functions…) which could result in some confusion/bugs.

We should review all the code and ensure that an error message is displayed whenever a namespace is not correctly formatted.

In the runtime, to avoid increasing the bundle size, we could perform this check only in development (when the constant SCRIPT_DEBUG is true).


Reported by @gziolo in Slack.

Step-by-step reproduction instructions

  1. Try to pass a namespace that does not comply with the format to the store() function in JavaScript or wp_interactivity_state() in PHP.
  2. An error should be displayed.

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions