Wp-graphql-woocommerce: Product categories come back HTML escaped but maybe shouldn't

Created on 28 Feb 2020  路  5Comments  路  Source: wp-graphql/wp-graphql-woocommerce

Describe the bug

A clear and concise description of what the bug is.

One of our product categories has an & in it

image

It comes back from WPGraphQL like so:

image

To Reproduce
Steps to reproduce the behavior:

  1. Go to Products
  2. Click on New Product
  3. Add Product with an & or > in it.
  4. Go to graphql and query for it
  5. See &

Expected behavior

A clear and concise description of what you expected to happen.

Since the form in WP Admin doesn't let you format the text, I think it makes sense to expect this field to come back unescaped.

Additional context

Add any other context about the problem here.

(woographql is awesome lol)

bug

Most helpful comment

@renatonascalves I agree this is something we need to address in WPGraphQL core. . .I noted some duplicate issues over here: https://github.com/wp-graphql/wp-graphql/issues/1169

I don't feel like I have a lot of clarity on what to do to address this. I think _something_ should be done for sure, but I'm not sure the best approach. 馃

All 5 comments

@ricokahler This is most likely related to a bigger issue in WPGraphQL. @jasonbahl Any ideas?

A simple html_entity_decode might do. Otherwise, the js app would be responsible to dealing with that. Not sure how the core plugin is handling that.

@renatonascalves Because the productCategories are registered using the core filters, meaning all the functionality related to the productCategories resolution is defined in the core plugin

I see it! So maybe we need to add the html_entity_decode here: https://github.com/wp-graphql/wp-graphql/blob/0453d4c7e2c91679e5f129bcb2b7b03816b03737/src/Model/Term.php#L82

It is outputting straight from the WP_Term object.

@renatonascalves I agree this is something we need to address in WPGraphQL core. . .I noted some duplicate issues over here: https://github.com/wp-graphql/wp-graphql/issues/1169

I don't feel like I have a lot of clarity on what to do to address this. I think _something_ should be done for sure, but I'm not sure the best approach. 馃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pmventura picture pmventura  路  3Comments

mehidi258 picture mehidi258  路  3Comments

IRediTOTO picture IRediTOTO  路  4Comments

mohaimenmahi picture mohaimenmahi  路  5Comments

huniqcast picture huniqcast  路  4Comments