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
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 2/5 1-3 小時 新手友好度 68/100
Vessel9817/onion-site-template#512 ·
維護者通常 1 天內回覆
-
nightly-tests
難度 2/5 1-3 小時 新手友好度 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
維護者通常 1 天內回覆
-
approved
難度 2/5 1-3 小時 新手友好度 85/100
fritzprix/libr-agent#3266 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
better-auth/better-auth#13101 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆