Redirect path captures double-encode percent-encoded reserved characters
Maintainer thường phản hồi trong vòng 5 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- node.js, typescript
- Lĩnh vực
- backend
Hướng nghiên cứu
Bắt đầu trong src/middleware/redirects.ts và theo dõi một segment đã được capture qua ba bước mà báo cáo nêu tên: decodeURI(rawPath), compileDestination(params) và lời gọi encodeURI(rawDestPath) trong formatDestination. Chạy repro.js được cung cấp với một bản build cục bộ để xác nhận bốn đầu ra %25XX, sau đó kiểm tra các test hiện có của middleware redirect để tìm pattern dùng để assert các header Location. Hoàn tất nghĩa là các escape dành riêng như %40 và %2B đi vào Location nguyên vẹn trong khi dấu cách thông thường vẫn được encode thành %20.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When a redirect destination uses captured path segments (such as :id or regex :1), percent-encoded reserved characters in the matched segment (%40, %2B, %2F, %3F, %23, %26, %3A, %3D, %2C, %3B, %24) are double-encoded into %25XX in the Location header.
Reproduction
Save as repro.js:
const http = require("node:http");
const superstatic = require("superstatic").server;
const app = superstatic({
port: 0,
host: "127.0.0.1",
config: {
redirects: [{ source: "/u/:id", destination: "/users/:id" }],
},
});
const server = app.listen(async () => {
const { port } = server.address();
for (const path of [
"/u/a%20b",
"/u/user%40example.com",
"/u/c%2B%2B",
"/u/a%3Fb",
]) {
await new Promise((resolve, reject) => {
http.get({ host: "127.0.0.1", port, path }, (res) => {
res.resume();
console.log(`${path} -> ${res.statusCode} ${res.headers.location}`);
resolve();
}).on("error", reject);
});
}
server.close();
});
Run:
npm install [email protected]
node repro.js
Actual output
/u/a%20b -> 301 /users/a%20b
/u/user%40example.com -> 301 /users/user%2540example.com
/u/c%2B%2B -> 301 /users/c%252B%252B
/u/a%3Fb -> 301 /users/a%253Fb
Expected output
/u/a%20b -> 301 /users/a%20b
/u/user%40example.com -> 301 /users/user%40example.com
/u/c%2B%2B -> 301 /users/c%2B%2B
/u/a%3Fb -> 301 /users/a%3Fb
Versions
superstatic:11.1.0andmain(a239edf)- Node.js:
v26.13.0
In src/middleware/redirects.ts, decodeURI(rawPath) leaves URI-reserved escapes (; / ? : @ & = + $ , #) percent-encoded, decodeURIComponent(this.compileDestination(params)) keeps them as %XX, and encodeURI(rawDestPath) in formatDestination encodes % again to %25.
Credit: https://ucsbplse.github.io/
- Ngôn ngữ chính
- TypeScript
- Star
- 1.1k
- Fork
- 90
- Merge trung bình
- 3 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 13
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của firebase/superstatic
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
firebase/superstatic#573 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
superstatic always loads configs from existing `firebase.json` file on project rootCó thể đã có người làm @jabrailkhalil đã nhận 45 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
firebase/superstatic#503 · 2 reaction ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Redirect inserting unexpected slash between index and parametersCó thể đã có người làm @sean0407 đã nhận 28 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
firebase/superstatic#300 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Rewrite upstream request headersĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
firebase/superstatic#286 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 32/100
firebase/superstatic#277 · 4 reaction ·
Maintainer thường phản hồi trong vòng 5 ngày
Tất cả issue của firebase/superstatic
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vercel-labs/ui#865 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
outline/outline#14638 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
wayfinder:grilling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
patricktree/cup#484 ·
-
bot:ai-assisted component:platform-js status:untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
midnightntwrk/platform-js#69 ·
Maintainer thường phản hồi trong vòng 1 ngày