Skip to content

Commit

Permalink
fix: jsonLD endpoint handles encoded urls
Browse files Browse the repository at this point in the history
  • Loading branch information
rpanfili committed Jan 14, 2025
1 parent 919dc43 commit 208e966
Show file tree
Hide file tree
Showing 2 changed files with 157 additions and 637 deletions.
12 changes: 11 additions & 1 deletion src/classes/jsonld/class-jsonld-endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function jsonld_using_meta( $request ) {

$meta_key = $request['meta_key'];
$params = $request->get_query_params();
$meta_value = urldecode( $params['meta_value'] );
$meta_value = $params['meta_value'];
$meta_values = array( $meta_value );
// Merchant Sync stores spaces as plus, so we need to restore them.
if ( strpos( $meta_value, ' ' ) > 0 ) {
Expand All @@ -238,6 +238,16 @@ public function jsonld_using_meta( $request ) {
$meta_values[] = str_replace( '+', ' ', $meta_value );
}

$contains_whitespace = strpos( $meta_value, ' ' ) !== false;
$contains_plus = strpos( $meta_value, '+' ) !== false;

if ( $contains_whitespace ) {
$meta_values[] = str_replace( ' ', '+', $meta_value );
}
if ( $contains_plus ) {
$meta_values[] = str_replace( '+', ' ', $meta_value );
}

$sql = "
SELECT pm.post_id AS id, %s AS type
FROM {$wpdb->postmeta} pm
Expand Down
Loading

0 comments on commit 208e966

Please sign in to comment.