UriTemplate expands ! ' ( ) * unencoded for non-reserved operators (RFC 6570 §3.2.1)
维护者通常 1 天内回复
@Urdemonlord 已经在做这个了。
开始于 2026年11月21日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 50/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- tooling
调研方向
Start in packages/core-internal/src/shared/uriTemplate.ts at the non-reserved branch of encodeValue, which delegates to encodeURIComponent; compare it with the + and # branches, which must keep ! ' ( ) * literal. Run the core-internal test suite to locate the existing uriTemplate tests, then add cases for {var}, {?q} and {.var} plus guards that {+var}/{#var} are unchanged. Done when non-reserved expansion emits %21 %27 %28 %29 %2A and lint/format checks pass; note the reporter says a patch and tests are already written, so coordinate before starting.
由索引模型根据 Issue 内容生成。
描述
encodeValue falls back to encodeURIComponent for every non-reserved operator, and encodeURIComponent deliberately leaves ! ' ( ) * unescaped. RFC 6570 §3.2.1 (simple string expansion) expands everything outside ALPHA / DIGIT / "-" / "." / "_" / "~", so those five characters must be percent-encoded.
Reproduction
import { UriTemplate } from '@modelcontextprotocol/core-internal/shared/uriTemplate';
new UriTemplate('{var}').expand({ var: 'Hello World!' });
// actual: Hello%20World!
// expected: Hello%20World%21
new UriTemplate('{var}').expand({ var: "a!b'c(d)e*f" });
// actual: a!b'c(d)e*f
// expected: a%21b%27c%28d%29e%2Af
Same for ., /, ? and & expressions, since they all go through encodeValue:
new UriTemplate('{?q}').expand({ q: 'a(b)' }); // actual ?q=a(b) expected ?q=a%28b%29
Why it matters
Expansion output is what gets handed to a resource or tool URI, so a value containing those characters produces a URI that differs from what every other RFC 6570 implementation emits for the same input (uritemplate, python-uritemplate, @std/uri, …). Anything matching on the concrete URI — including this repo's own match() when a caller builds a URI elsewhere and matches it here — sees a different string. Parentheses and apostrophes are common in real values: file names, titles, search queries.
match() itself is unaffected: it returns the raw matched span and never decodes, so this change cannot desynchronise expand/match.
Where
packages/core-internal/src/shared/uriTemplate.ts, encodeValue — the non-reserved branch. The + and # branches are correct as they are: reserved expansion keeps sub-delims, so ! ' ( ) * must stay literal there.
Fix
Percent-encode those five characters after encodeURIComponent, leaving the reserved branch alone. I have this written with tests (including a guard that {+var} and {#var} still keep the characters) and all 1861 core-internal tests plus eslint/prettier/tsgo passing, so say the word and I'll open the PR.
Note while I was in there: expand() on a multi-variable expression ignores the operator entirely and skips encoding ({.var,hello} with hello: 'Hello World!' gives value,Hello World! instead of .value.Hello%20World%21). That is a separate defect from #2166 (which is the match() side) and I have kept it out of the fix above to keep the diff reviewable — happy to file it separately if you'd like it tracked.
- 主要语言
- TypeScript
- 星标
- 13.8k
- 派生
- 2.5k
- 平均合并
- 6 天 23 小时
- 30 天内合并 PR
- 2
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
modelcontextprotocol/typescript-sdk 的其他 Issue
-
v2
难度 1/5 1 小时以内 新手友好度 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 条评论 ·
维护者通常 1 天内回复
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`可能已有人在做 @mgoldsborough 于 6 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 78/100
modelcontextprotocol/typescript-sdk#3249 ·
维护者通常 1 天内回复
-
v2
难度 2/5 1-3 小时 新手友好度 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 条评论 ·
维护者通常 1 天内回复
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` reply可能已有人在做 @Tidehyc 于 7 天前认领。 未关闭v2
难度 2/5 1-3 小时 新手友好度 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 条评论 ·
维护者通常 1 天内回复
-
UriTemplate.match() throws a TypeError on an empty expression it accepts可能已有人在做 @yunusemrejs 于 12 天前认领。 未关闭v1 v2
难度 2/5 1-3 小时 新手友好度 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 条评论 ·
维护者通常 1 天内回复
查看 modelcontextprotocol/typescript-sdk 的全部 Issue
相似的 Issue
-
clawsweeper:intake:bug clawsweeper:intake:needs-environment
难度 2/5 1-3 小时 新手友好度 82/100
openclaw/openclaw#212827 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
KT-2245 e2e specs that call the backend directly fall back to the developer's own Kronn on :3140未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
Use one constant for the 10,000-character input limit可能已有人在做 @NginxL 今天认领。 未关闭good first issue refactor
难度 2/5 1-3 小时 新手友好度 78/100
aniru-dh21/snap-validate#51 ·
维护者通常 1 天内回复
-
dependencies effort: small good first issue priority: low
难度 1/5 1-3 小时 新手友好度 88/100
TMHSDigital/screencast-mcp#509 ·
维护者通常 1 天内回复
-
from-review tech-debt testing
难度 2/5 1-3 小时 新手友好度 82/100
blamechris/chroxy#9520 ·
维护者通常 1 天内回复