GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: fix MIME overmatch in data URLs by andremralves · Pull Request #49104 · nodejs/node

Conversation

@andremralves

@andremralves andremralves commented Aug 11, 2023

Copy link
Copy Markdown
Contributor

This commit adds the delimiters ^ and $ to the regex that matches the MIME types for "data:URLs".
Fixes: #48957

I also added a new test case that expects an ERR_UNKNOWN_MODULE_FORMAT message for MIME types like this: data:WRONGtext/javascriptFORMAT.

This is my first time contributing to node. Let me know if I did everything right 😄.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss reacted with eyes emoji
All reactions
  • 👀 1 reaction
@nodejs-github-bot

nodejs-github-bot commented Aug 11, 2023

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/modules
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run. labels Aug 11, 2023
GeoffreyBooth
GeoffreyBooth reviewed Aug 11, 2023
View reviewed changes

@GeoffreyBooth GeoffreyBooth left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! Looks good, just some questions.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread lib/internal/modules/esm/formats.js Outdated

@GeoffreyBooth GeoffreyBooth Aug 11, 2023

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be any other extra “query params,” so to speak, besides charset=utf-8? If so, then we can’t add the $.

This is another issue, but is utf-8 / utf8 the only permitted charset?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@aduh95 aduh95 Aug 11, 2023

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/^\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?$/i,
/^\s*(text|application)\/javascript\s*(;|$)/i,

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@andremralves andremralves Aug 11, 2023

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be any other extra “query params,” so to speak, besides charset=utf-8? If so, then we can’t add the $.

I read the MDN article about "Common MIME types" and found a link to the RFC of text/javascript MIME type. They don't mention any other param other than the charset parameter and say that it's optional.

Also, I found out that the first implementation of this code was only matching text/javascript and then someone refactored it to inclued the support for the optional charset parameter.

This is another issue, but is utf-8 / utf8 the only permitted charset?

According to that RFC: "Module goal sources MUST always be processed as UTF-8.", so I think we should be good using just utf-8.

Thanks for the feedback 🚀

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@aduh95

aduh95 commented Aug 11, 2023

Copy link
Copy Markdown
Contributor

This is another issue, but is utf-8 / utf8 the only permitted charset?

I'd say it's not related to this PR, but defaultLoad is ignoring all the params (including charset) except for base64.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

GeoffreyBooth
GeoffreyBooth approved these changes Aug 11, 2023
View reviewed changes
@aduh95

aduh95 commented Aug 11, 2023

Copy link
Copy Markdown
Contributor

Can you fix the test failure please?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andremralves

andremralves commented Aug 11, 2023

Copy link
Copy Markdown
Contributor Author

Can you fix the test failure please?

Oh, I know what happened. I fixed the linting and the error message ended up being wrong. I will fix.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andremralves
andremralves force-pushed the fix-mime branch from 5c8af6c to fc3b4dc Compare August 11, 2023 16:29
@andremralves
andremralves requested a review from aduh95 August 11, 2023 16:32
@andremralves

andremralves commented Aug 11, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@aduh95 I fixed the test failure.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@andremralves

andremralves commented Aug 11, 2023

Copy link
Copy Markdown
Contributor Author

I believe the failure now is not related to this PR. There are other PRs with the same failure.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95
aduh95 force-pushed the fix-mime branch from fc3b4dc to b244935 Compare August 13, 2023 09:08
@andremralves @aduh95
lib: fix MIME overmatch in data URLs
00dbd94
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for "data:URLs".
Fixes: nodejs#48957
@aduh95
aduh95 force-pushed the fix-mime branch from b244935 to 00dbd94 Compare August 13, 2023 09:10
aduh95
aduh95 approved these changes Aug 13, 2023
View reviewed changes
@aduh95 aduh95 added author ready PRs with CI started, the required approvals, and no outstanding review comments. request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. labels Aug 13, 2023
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Aug 13, 2023
@nodejs-github-bot

nodejs-github-bot commented Aug 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/53267/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/53269/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/53279/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Aug 13, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/53284/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95 aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Aug 13, 2023
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Aug 13, 2023
@nodejs-github-bot

nodejs-github-bot commented Aug 13, 2023

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/49104
✔  Done loading data for nodejs/node/pull/49104
----------------------------------- PR info ------------------------------------
Title      lib: fix MIME overmatch in data URLs (#49104)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     andremralves:fix-mime -> nodejs:main
Labels     esm, author ready, needs-ci
Commits    1
 - lib: fix MIME overmatch in data URLs
Committers 1
 - Antoine du Hamel 
PR-URL: https://github.com/nodejs/node/pull/49104
Fixes: https://github.com/nodejs/node/issues/48957
Reviewed-By: Geoffrey Booth 
Reviewed-By: Antoine du Hamel 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/49104
Fixes: https://github.com/nodejs/node/issues/48957
Reviewed-By: Geoffrey Booth 
Reviewed-By: Antoine du Hamel 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 11 Aug 2023 05:08:02 GMT
   ✔  Approvals: 2
   ✔  - Geoffrey Booth (@GeoffreyBooth) (TSC): https://github.com/nodejs/node/pull/49104#pullrequestreview-1573705440
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/49104#pullrequestreview-1575747202
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2023-08-13T17:48:39Z: https://ci.nodejs.org/job/node-test-pull-request/53284/
- Querying data for job/node-test-pull-request/53284/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 49104
From https://github.com/nodejs/node
 * branch                  refs/pull/49104/merge -> FETCH_HEAD
✔  Fetched commits as b5da2f4dad72..00dbd9454ae8
--------------------------------------------------------------------------------
[main a344cdb5e6] lib: fix MIME overmatch in data URLs
 Author: Andre Alves 
 Date: Fri Aug 11 01:47:22 2023 -0300
 2 files changed, 4 insertions(+), 1 deletion(-)
   ✔  Patches applied
--------------------------------------------------------------------------------
   ✘  Git found no trailers in the original commit message, but 'Fixes: https://github.com/nodejs/node/issues/48957' is present and should be a trailer.
https://github.com/nodejs/node/actions/runs/5849556424
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@aduh95
aduh95 merged commit 7139198 into nodejs:main Aug 13, 2023
@aduh95

aduh95 commented Aug 13, 2023

Copy link
Copy Markdown
Contributor

Landed in 7139198, thanks for the contribution 🎉

andremralves reacted with hooray emoji
All reactions
  • 🎉 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Aug 14, 2023
CI Reliability 2023-08-14 nodejs/reliability#636
Open
25 tasks
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
@andremralves @Ceres6
lib: fix MIME overmatch in data URLs
995432c
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: nodejs#49104
Fixes: nodejs#48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@github-actions github-actions Bot mentioned this pull request Aug 15, 2023
CI Reliability 2023-08-15 nodejs/reliability#637
Open
22 tasks
RafaelGSS pushed a commit that referenced this pull request Aug 15, 2023
@andremralves @RafaelGSS
lib: fix MIME overmatch in data URLs
e564018
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: #49104
Fixes: #48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@UlisesGascon UlisesGascon mentioned this pull request Aug 15, 2023
v20.6.0 proposal #49185
Merged
RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Aug 15, 2023
@andremralves @RafaelGSS
lib: fix MIME overmatch in data URLs
c1f7728
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: nodejs#49104
Fixes: nodejs#48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@github-actions github-actions Bot mentioned this pull request Aug 16, 2023
CI Reliability 2023-08-16 nodejs/reliability#638
Open
24 tasks
@andremralves
andremralves deleted the fix-mime branch August 16, 2023 05:02
@joyeecheung joyeecheung mentioned this pull request Aug 16, 2023
test: make test-perf-hooks more robust and work with workers #49197
Merged
RafaelGSS pushed a commit that referenced this pull request Aug 16, 2023
@andremralves @RafaelGSS
lib: fix MIME overmatch in data URLs
023e299
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: #49104
Fixes: #48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 17, 2023
@andremralves @RafaelGSS
lib: fix MIME overmatch in data URLs
b66a3c1
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: #49104
Fixes: #48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
targos pushed a commit that referenced this pull request Nov 27, 2023
@andremralves @targos
lib: fix MIME overmatch in data URLs
981aa78
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: #49104
Fixes: #48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@targos targos mentioned this pull request Nov 28, 2023
v18.19.0 release proposal #50953
Merged
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
@sercher
lib: fix MIME overmatch in data URLs
c2adb95
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: nodejs/node#49104
Fixes: nodejs/node#48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
@sercher
lib: fix MIME overmatch in data URLs
ce98226
This commit adds the delimiters ^ and $ to the regex that matches the
MIME types for `data:` URLs.

PR-URL: nodejs/node#49104
Fixes: nodejs/node#48957
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@GeoffreyBooth GeoffreyBooth GeoffreyBooth approved these changes
@aduh95 aduh95 aduh95 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. esm Issues and PRs related to the ECMAScript Modules implementation. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

MIME type overmatch in data URLs

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@andremralves @nodejs-github-bot @aduh95 @GeoffreyBooth
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.