Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve white space encode handling on jsonLD exposition endpoint #1756

Open
rpanfili opened this issue Jan 10, 2025 · 0 comments
Open

Improve white space encode handling on jsonLD exposition endpoint #1756

rpanfili opened this issue Jan 10, 2025 · 0 comments

Comments

@rpanfili
Copy link
Contributor

if ( strpos( $meta_value, ' ' ) > 0 ) {
$meta_values[] = str_replace( ' ', '+', $meta_value );
} elseif ( strpos( $meta_value, '+' ) > 0 ) {
$meta_values[] = str_replace( '+', ' ', $meta_value );
}

Since strpos php function returns boolean false when the provided substring (needle) was not found in the string (haystack), I think this logic is prone to some side-case issues when those chars appears in the first position (which is 0).

To have a better and more reliable and data-agnostic approach I suggest to reword this like:

if (false !== strpos($meta_value, ' ')) {
  [...]
} elseif (false !== strpos($meta_value, '+')) {
  [...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant