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

Closes #7142: 3.18: data-wpr-hosted-gf-parameters sometimes isnot having the original data structure with some templates #7157

Merged

Conversation

Miraeld
Copy link
Contributor

@Miraeld Miraeld commented Dec 1, 2024

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

  • Bug fix (non-breaking change which fixes an issue).

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

  • I validated all the Acceptance Criteria. If possible, provide screenshots or videos.
  • I triggered all changed lines of code at least once without new errors/warnings/notices.
  • I implemented built-in tests to cover the new/changed code.

Code style

  • I wrote a self-explanatory code about what it does.
  • I protected entry points against unexpected inputs.
  • I did not introduce unnecessary complexity.
  • Output messages (errors, notices, logs) are explicit enough for users to understand the issue and are actionnable.

@Miraeld Miraeld added the type: bug Indicates an unexpected problem or unintended behavior label Dec 1, 2024
@Miraeld Miraeld self-assigned this Dec 1, 2024
@Miraeld Miraeld requested a review from a team December 1, 2024 17:42
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for dce9cce1 100.00% (target: 50.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (dce9cce) Report Missing Report Missing Report Missing
Head commit (94ce0d9) 38425 16868 43.90%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#7157) 2 2 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@hanna-meda
Copy link

@Miraeld, Thank you for this PR.
We can still see a difference between the original data structure and data after hosted gf locally applied, the &#038; which represents the "&" symbol is no longer there. Should we have it? @wp-media/product @piotrbak
Screenshot 2024-12-02 at 15 32 00

@hanna-meda
Copy link

Having &#038; or & shouldn't change a thing, based on slack discussion. Moving this to QA Done.

@hanna-meda hanna-meda merged commit 09703c4 into feature/host-google-fonts Dec 3, 2024
12 of 13 checks passed
@hanna-meda hanna-meda deleted the fix/7142-gf-parameters-not-full branch December 3, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.18: data-wpr-hosted-gf-parameters sometimes isnot having the original data structure with some templates
3 participants