UriTemplate expands ! ' ( ) * unencoded for non-reserved operators (RFC 6570 §3.2.1)
Maintainer antworten meist innerhalb von 1 Tag
@Urdemonlord arbeitet bereits daran.
Seit 21.11.2026.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 50/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- typescript
- Bereich
- tooling
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 13.8k
- Forks
- 2.5k
- Ø Merge
- 6 T. 23 Std.
- Gemergte PRs (30 T.)
- 2
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus modelcontextprotocol/typescript-sdk
-
v2
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
modelcontextprotocol/typescript-sdk#3270 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
`callTool` with `allowInputRequired: true` throws on an `input_required` result when the tool declares an `outputSchema`Evtl. vergeben @mgoldsborough hat das vor 6 Tagen übernommen. Offenv2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
modelcontextprotocol/typescript-sdk#3249 ·
Maintainer antworten meist innerhalb von 1 Tag
-
v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
modelcontextprotocol/typescript-sdk#3243 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
TypeScript client accepts an unknown `resultType` in the first `server/discover` replyEvtl. vergeben @Tidehyc hat das vor 7 Tagen übernommen. Offenv2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
modelcontextprotocol/typescript-sdk#3235 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
UriTemplate.match() throws a TypeError on an empty expression it acceptsEvtl. vergeben @yunusemrejs hat das vor 12 Tagen übernommen. Offenv1 v2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 80/100
modelcontextprotocol/typescript-sdk#3221 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in modelcontextprotocol/typescript-sdk
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Vessel9817/onion-site-template#512 ·
Maintainer antworten meist innerhalb von 1 Tag
-
nightly-tests
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
BlackBeltTechnology/pi-agent-dashboard#1256 ·
Maintainer antworten meist innerhalb von 1 Tag
-
approved
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
fritzprix/libr-agent#3266 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
better-auth/better-auth#13101 · 1 Kommentar · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag