Shopify / shopify-cli

Shopify CLI helps you build against the Shopify platform faster.
https://shopify.dev/tools/cli
Other
1.01k stars 201 forks source link

Do not `replace_asset_urls` in font bodies #2721

Closed Poitrin closed 1 year ago

Poitrin commented 1 year ago

WHY are these changes introduced?

Fixes https://github.com/Shopify/cli/issues/1199

Starting with Ruby 3.2 – Homebrew formula just says depends_on "ruby", so that’s why such kind of issues appear now – body.join.gsub raises the error invalid byte sequence in UTF-8 when body.join is a font body (which of course doesn’t contain any URLs or other readable characters).

WHAT is this pull request doing?

  1. Does not call replace_asset_urls when path starts with /fonts.
  2. In case other "non-gsubable" strings are being gsubed and the same ArgumentError containing the message invalid byte sequence is raised, body will simply be returned without any replacements.

How to test your changes?

Test it with both Ruby 3.1 and 3.2:

  1. cd into a theme directory
  2. Call DEBUG=true shopify theme serve
  3. Open http://127.0.0.1:9292/
  4. Verify that no Internal server error is thrown

Post-release steps

Update checklist