[Bug]: CJS `import.meta.url` shim does not percent-encode `#` or `%` in paths
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- node.js, typescript
- 領域
- build-system
調査の方向性
プロジェクト内でデフォルトの shims.cjs['import.meta.url'] 定義を検索し、CJS shim がファイル URL をどのように構築するかを確認してください。# と % を含むパスで再現し、shim が期待どおりにエンコードされた URL を生成すること、および fileURLToPath と new URL('./asset', import.meta.url) が正しく解決されることを確認してください。Issue にはテストファイルの指定がないため、既存の shim テストを探し、そこでカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
説明
Version
System:
OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
CPU: (64) x64 Intel(R) Xeon(R) CPU @ 2.80GHz
Memory: 217.67 GB / 251.88 GB
Container: Yes
Shell: 5.2.15 - /bin/bash
npmPackages:
@rslib/core: ^1.0.6 => 1.0.6 (@rspack/core 2.3.1, main b6645e20)
Details
The default shims.cjs['import.meta.url'] builds the file URL as new (require('url'.replace('', '')).URL)('file:' + __filename).href. Concatenating 'file:' + __filename does not percent-encode # or % in the filesystem path, so # is parsed as a URL fragment delimiter and %41 is treated as a percent-encoded sequence. Passing the shimmed import.meta.url to fileURLToPath(import.meta.url) or new URL('./asset', import.meta.url) then resolves to the wrong path (truncated at # or with % sequences decoded).
Using url.pathToFileURL(__filename).href encodes special characters in the path properly.
Reproduce link
https://gist.github.com/trackoor/33741ecfe4ad7ae3958c7de54f4a1e38
Reproduce Steps
In a directory named we#ird %41 dir with { "name": "repro", "type": "module" } in package.json:
// src/index.js
import { fileURLToPath } from "node:url";
export const url = import.meta.url;
export const file = fileURLToPath(import.meta.url);
// rslib.config.mjs
import { defineConfig } from "@rslib/core";
export default defineConfig({ lib: [{ format: "cjs" }] });
Run npx rslib build, then run:
node -e 'console.log(require("./dist/index.cjs"))'
Actual output:
{
file: '/.../we',
url: 'file:///.../we#ird%20%41%20dir/dist/index.cjs'
}
Expected output:
{
file: '/.../we#ird %41 dir/dist/index.cjs',
url: 'file:///.../we%23ird%20%2541%20dir/dist/index.cjs'
}
Credit: https://ucsbplse.github.io/
- 主要言語
- TypeScript
- スター
- 1k
- フォーク
- 68
- 平均マージ
- 9時間 13分
- マージ済み PR(30日)
- 52
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
web-infra-dev/rslib のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
web-infra-dev/rslib#2013 ·
メンテナーはふだん 1 日以内に返信
-
[Feature]: Proposal to replace @ast-grep/napi with @swc-next/parser in rsbuild-plugin-dts対応中かも @elecmonkey が 4 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
web-infra-dev/rslib#1996 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Rspack
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
web-infra-dev/rslib#1839 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Feature]: resolve new URL as entry対応中かも @elecmonkey が 65 日前に担当しました。 オープンRspack
web-infra-dev/rslib#1825 · リアクション 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
[Bug]: Code execution order changed after bundling再び着手できるかも @JSerFeng が 245 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンRspack
web-infra-dev/rslib#1519 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
web-infra-dev/rslib の issue をすべて見る
似ている issue
-
area:cards enhancement ready-for-agent
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
fil-donadoni/tolaria#8883 ·
メンテナーはふだん 1 日以内に返信
-
xsd:integer cast from a string rejects negative numbers, a leading + and surrounding whitespaceオープンbug 🐛
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
comunica/comunica#1960 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Waiting for: Product Owner
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
getsentry/sentry-javascript#26203 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bytedance/flowgram.ai#1235 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
devswha/herdr-web-ui#3325 ·