Closes #7142: 3.18: data-wpr-hosted-gf-parameters sometimes isnot having the original data structure with some templates #7157
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7142
This fix ensures the data-wpr-hosted-gf-parameters contains the full query string by decoding the URL before processing. Previously, the query string was truncated due to improperly encoded characters like & breaking the URL structure.
Type of change
Detailed scenario
To reproduce the issue:
1. Enable “Host Google Fonts Locally.”
2. Visit a page with the following URL: https://fonts.googleapis.com/css?family=Roboto%3A400%2C100%2C300%2C100italic%2C300italic%2C400italic%2C500%2C500italic%2C700%2C700italic%2C900%2C900italic%7CPT%20Sans%3A400%2C700%2C400italic%7CMontserrat%3A400%2C600%2C700%7CTangerine&display=swap.
3. Check the data-wpr-hosted-gf-parameters attribute in the page’s source.
You will notice the query string is incomplete or truncated, especially after the &display=swap portion.
The fix ensures the full value of the data-wpr-hosted-gf-parameters attribute is present.
Technical description
Documentation
This fix involves decoding the URL using html_entity_decode() before parsing it with wp_parse_url(). This prevents issues with broken query parameters caused by HTML-encoded characters like &.
The updated code now ensures the query string is fully captured by handling the decoding step before URL parsing.
New dependencies
None
Risks
None
Mandatory Checklist
Code validation
Code style