req.subdomains splits an IPv6 host that contains dots
维护者通常 1 天内回复
@johnnyhuirilef 已经在做这个了。
开始于 2026年10月20日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, node.js
调研方向
从 lib/request.js 中的 req.subdomains 开始,阅读它如何使用 net.isIP() 检查 req.hostname。在现有的 IPv6 子域名测试旁,添加一个针对带点分隔的 IPv4-mapped IPv6 主机的回归测试。默认偏移量返回 [],且偏移量 0 保留完整的方括号括起的主机,即表示完成;issue 报告了预期输出。
由索引模型根据 Issue 内容生成。
描述
Hi! 🙂 req.subdomains splits an IPv6 host that contains dots.
Environment information
Version: express 5.3.0 (4.22.3 gives the same result)
Platform: Darwin 27.0.0
Node.js version: v24.21.0
Any other relevant information: None.
What steps will reproduce the bug?
req.subdomains does not split a host that is an IP address. This works for [::1]. An IPv6 address can also contain dots, for example the IPv4-mapped address [::ffff:127.0.0.1]. req.subdomains splits that host on the dots:
const express = require('express')
const app = express()
app.get('/', (req, res) => res.json(req.subdomains))
app.listen(3000)
curl -H 'Host: [::1]' http://localhost:3000/
# []
curl -H 'Host: [::ffff:127.0.0.1]' http://localhost:3000/
# ["0","[::ffff:127"]
Full repro, with npm run repro: https://github.com/johnnyhuirilef/expressjs-repros/tree/main/subdomains-ipv6-dotted-host
Note: fetch() rewrites the host to [::ffff:7f00:1], so it does not show the bug. curl, http.get() and X-Forwarded-Host (with trust proxy) send the host as written.
What is the expected behavior?
[] for [::ffff:127.0.0.1], the same as for [::1]. With subdomain offset set to 0, the expected value is ["[::ffff:127.0.0.1]"].
What do you see instead?
["0","[::ffff:127"]. With subdomain offset set to 0: ["1]","0","0","[::ffff:127"].
Additional information
req.hostname keeps the brackets of an IPv6 literal. req.subdomains passes that value to net.isIP() in lib/request.js, and isIP('[::ffff:127.0.0.1]') returns 0. The existing [::1] test passes only because that address has no dots.
I have a fix with tests. Happy to open a PR 🙌
- 主要语言
- JavaScript
- 星标
- 69.7k
- 派生
- 25.6k
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
expressjs/express 的其他 Issue
-
Outdated res.send() syntax in lib/response.js documentation example可能重新可做 关联的 PR 已关闭且未合并。 未关闭docs
难度 1/5 1 小时以内 新手友好度 95/100
expressjs/express#7588 · 1 条评论 ·
维护者通常 1 天内回复
-
4.x deps module:body-parser
难度 1/5 1 小时以内 新手友好度 75/100
expressjs/express#7564 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Update to mocha 12.x可能已有人在做 @ganeshghutukade-04 于 26 天前认领。 未关闭deps
难度 2/5 1-3 小时 新手友好度 67/100
expressjs/express#7547 · 6 条评论 ·
维护者通常 1 天内回复
-
Readme: project name 'express.js' is not capitalized可能重新可做 关联的 PR 已关闭且未合并。 未关闭
难度 1/5 1 小时以内 新手友好度 95/100
维护者通常 1 天内回复
-
res.send(ArrayBuffer) silently sends {} as JSON可能已有人在做 @myselfsiddharth 于 137 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
expressjs/express#7362 · 7 条评论 ·
维护者通常 1 天内回复
查看 expressjs/express 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 63/100
anothaDev/luci-theme-vantage#143 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
kingcharleslzy-ai/dsh-purge#282 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 72/100
-
a-corriger bug
难度 2/5 1-3 小时 新手友好度 86/100
christian-raj/S-Aloha#340 ·
-
area:image documentation good first issue
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复