fix(matrix): tolerate malformed location params · openclaw/openclaw@1d5f015
vincentkoc
·
2026-05-14
·
via Recent Commits to openclaw:main
File tree
extensions/matrix/src/matrix/monitor
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ Docs: https://docs.openclaw.ai
|
17 | 17 | - Models config/auth: stop inferring provider env-var markers from broad `^[A-Z_][A-Z0-9_]*$` strings, and resolve config-backed provider `apiKey` values only through structured env SecretRefs (`secrets.providers[id]` / `secrets.defaults`), so unrelated env vars cannot accidentally become provider credentials. Thanks @sallyom. |
18 | 18 | - Media fetch: skip allocating and buffering the response body for bodyless media responses (HEAD probes and 204-style empty bodies), avoiding wasted heap on streams that carry no payload. Thanks @shakkernerd. |
19 | 19 | - CLI/onboarding: forward provider-specific auth flags (e.g. `--openai-api-key`) through the onboarding wizard so they reach provider auth methods via `ctx.opts`, letting `--openai-api-key "$OPENAI_API_KEY"` skip the redundant "use existing env var?" prompt in non-interactive harnesses. (#81669) Thanks @sjf. |
| 20 | +- Matrix: ignore malformed percent-encoding in optional location URI parameters instead of letting a bad `geo:` event abort inbound message handling. |
20 | 21 | - Plugins: discover provider plugins from `setup.providers[].envVars` credentials during provider discovery while keeping the deprecated `providerAuthEnvVars` fallback. (#81542) Thanks @JARVIS-Glasses. |
21 | 22 | - Docs/Codex harness: clarify that per-agent `CODEX_HOME` isolates `~/.codex` while inherited `HOME` intentionally keeps `.agents` discovery and subprocess user-home state available. |
22 | 23 | - CLI/plugins: keep bare plugin and parent-command help on the lightweight path, avoiding plugin registry discovery before rendering help. |
|
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { resolveMatrixLocation } from "./location.js"; |
| 3 | +import { EventType } from "./types.js"; |
| 4 | + |
| 5 | +describe("resolveMatrixLocation", () => { |
| 6 | +it("decodes encoded geo uri accuracy", () => { |
| 7 | +const result = resolveMatrixLocation({ |
| 8 | +eventType: EventType.Location, |
| 9 | +content: { |
| 10 | +msgtype: EventType.Location, |
| 11 | +geo_uri: "geo:1.5,2.5;u=%31%30", |
| 12 | +}, |
| 13 | +}); |
| 14 | + |
| 15 | +expect(result?.context).toMatchObject({ |
| 16 | +LocationLat: 1.5, |
| 17 | +LocationLon: 2.5, |
| 18 | +LocationAccuracy: 10, |
| 19 | +}); |
| 20 | +}); |
| 21 | + |
| 22 | +it("ignores malformed geo uri parameter encoding", () => { |
| 23 | +const result = resolveMatrixLocation({ |
| 24 | +eventType: EventType.Location, |
| 25 | +content: { |
| 26 | +msgtype: EventType.Location, |
| 27 | +geo_uri: "geo:1.5,2.5;u=%zz", |
| 28 | +}, |
| 29 | +}); |
| 30 | + |
| 31 | +expect(result?.context).toMatchObject({ |
| 32 | +LocationLat: 1.5, |
| 33 | +LocationLon: 2.5, |
| 34 | +}); |
| 35 | +expect(result?.context.LocationAccuracy).toBeUndefined(); |
| 36 | +}); |
| 37 | +}); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,14 @@ type GeoUriParams = {
|
17 | 17 | accuracy?: number; |
18 | 18 | }; |
19 | 19 | |
| 20 | +function decodeGeoUriParamValue(value: string): string { |
| 21 | +try { |
| 22 | +return decodeURIComponent(value); |
| 23 | +} catch { |
| 24 | +return value; |
| 25 | +} |
| 26 | +} |
| 27 | + |
20 | 28 | function parseGeoUri(value: string): GeoUriParams | null { |
21 | 29 | const trimmed = value.trim(); |
22 | 30 | if (!trimmed) { |
@@ -51,7 +59,7 @@ function parseGeoUri(value: string): GeoUriParams | null {
|
51 | 59 | continue; |
52 | 60 | } |
53 | 61 | const valuePart = rawValue.trim(); |
54 | | -params.set(key, valuePart ? decodeURIComponent(valuePart) : ""); |
| 62 | +params.set(key, valuePart ? decodeGeoUriParamValue(valuePart) : ""); |
55 | 63 | } |
56 | 64 | |
57 | 65 | const accuracyRaw = params.get("u"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。