Skip to content

Commit d02cc70

Browse files
tmoostingclaude
andcommitted
0.99.1: openers_for refuses a link that opens no app
A tools row whose open template uses javascript:, data:, vbscript:, file:, blob: or about: (in any case), or does not begin with its scheme, raises TypeError naming the row. Four cases in the shared openers fixture (61, the same bytes as the npm SDK's), red before the rule and on a planted mutant after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9bf375d commit d02cc70

5 files changed

Lines changed: 154 additions & 8 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The package version runs on its own semver; the schema it is generated from is `
44

55
## Unreleased
66

7+
## 0.99.1 (2026-10-31)
8+
9+
- **`openers_for` refuses a link that opens no app.** A tools list row whose `open` template uses `javascript:`, `data:`, `vbscript:`, `file:`, `blob:` or `about:` (in any case), or does not begin with its scheme, raises `TypeError` naming the row. Four cases in the shared openers fixture (61, the same bytes as the npm SDK's).
10+
711
## 0.99.0 (2026-10-31)
812

913
- **`tool="onlyworlds"` is the site itself.** `openers_for` gives the site's own row "You are here" when the surface names itself `onlyworlds`, before "Needs a connection", as a tool's own row already did. Three cases in the shared openers fixture (57 now, the same bytes as the npm SDK's).

‎src/onlyworlds/_version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.99.0"
1+
__version__ = "0.99.1"

‎src/onlyworlds/openers.py‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,25 @@ def _fail(what: str) -> NoReturn:
6666
raise TypeError(f"openers_for: {what}")
6767

6868

69+
_NO_APP = ("javascript", "data", "vbscript", "file", "blob", "about")
70+
_SCHEME = re.compile(r"^([A-Za-z][A-Za-z0-9+.-]*):")
71+
72+
6973
def _template(row: str, key: str, value: object) -> str | None:
70-
"""A template string or None."""
71-
if value is None or isinstance(value, str):
72-
return value
73-
_fail(f"tool {row}: open.{key} is a link template or None")
74+
"""A template string or None. A template begins with its scheme (a browser drops leading spaces before
75+
reading one), and a scheme that opens no app (a press would run what the link carries) is refused, in
76+
any case."""
77+
if value is None:
78+
return None
79+
if not isinstance(value, str):
80+
_fail(f"tool {row}: open.{key} is a link template or None")
81+
m = _SCHEME.match(value)
82+
if m is None:
83+
_fail(f"tool {row}: open.{key} begins with its scheme")
84+
scheme = m.group(1).lower()
85+
if scheme in _NO_APP:
86+
_fail(f"tool {row}: open.{key} is a {scheme}: link, which opens no app")
87+
return value
7488

7589

7690
def openers_for(

‎tests/fixtures/openers.fixture.json‎

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,63 @@
150150
}
151151
}
152152
],
153-
"empty": []
153+
"empty": [],
154+
"script-link": [
155+
{
156+
"id": "skiff",
157+
"name": "Skiff",
158+
"url": "https://skiff.example",
159+
"client": "skiff",
160+
"rung": "listed",
161+
"open": {
162+
"world": "javascript:alert(1)//{world}",
163+
"element": null,
164+
"needs": null
165+
}
166+
}
167+
],
168+
"script-link-case": [
169+
{
170+
"id": "skiff",
171+
"name": "Skiff",
172+
"url": "https://skiff.example",
173+
"client": "skiff",
174+
"rung": "listed",
175+
"open": {
176+
"world": "JavaScript:alert(1)//{world}",
177+
"element": null,
178+
"needs": null
179+
}
180+
}
181+
],
182+
"data-link": [
183+
{
184+
"id": "skiff",
185+
"name": "Skiff",
186+
"url": "https://skiff.example",
187+
"client": "skiff",
188+
"rung": "listed",
189+
"open": {
190+
"world": "https://skiff.example/{world}",
191+
"element": "data:text/html,{id}",
192+
"needs": null
193+
}
194+
}
195+
],
196+
"space-first": [
197+
{
198+
"id": "skiff",
199+
"name": "Skiff",
200+
"url": "https://skiff.example",
201+
"client": "skiff",
202+
"rung": "listed",
203+
"open": {
204+
"world": " https://skiff.example/{world}",
205+
"element": null,
206+
"needs": null
207+
}
208+
}
209+
]
154210
},
155211
"cases": [
156212
{
@@ -2027,6 +2083,78 @@
20272083
"error": "type",
20282084
"names": "needs"
20292085
}
2086+
},
2087+
{
2088+
"name": "a-script-link-is-refused",
2089+
"why": "a template whose scheme opens no app (javascript:, data:, vbscript:, file:, blob:, about:) is refused, never drawn as a row a press would run",
2090+
"tools": "script-link",
2091+
"kind": "world",
2092+
"address": {
2093+
"form": "human",
2094+
"world": "0199c3a1-7b2e-7c3d-8e4f-5a6b7c8d9e0f"
2095+
},
2096+
"surface": {
2097+
"audience": "member",
2098+
"signed_in": true
2099+
},
2100+
"refuse": {
2101+
"error": "type",
2102+
"names": "opens no app"
2103+
}
2104+
},
2105+
{
2106+
"name": "a-script-link-in-any-case-is-refused",
2107+
"why": "a scheme is read in any case, as a browser reads it",
2108+
"tools": "script-link-case",
2109+
"kind": "world",
2110+
"address": {
2111+
"form": "human",
2112+
"world": "0199c3a1-7b2e-7c3d-8e4f-5a6b7c8d9e0f"
2113+
},
2114+
"surface": {
2115+
"audience": "member",
2116+
"signed_in": true
2117+
},
2118+
"refuse": {
2119+
"error": "type",
2120+
"names": "opens no app"
2121+
}
2122+
},
2123+
{
2124+
"name": "a-data-link-is-refused",
2125+
"why": "the element template is held to the same rule as the world's, on a world menu too",
2126+
"tools": "data-link",
2127+
"kind": "world",
2128+
"address": {
2129+
"form": "human",
2130+
"world": "0199c3a1-7b2e-7c3d-8e4f-5a6b7c8d9e0f"
2131+
},
2132+
"surface": {
2133+
"audience": "member",
2134+
"signed_in": true
2135+
},
2136+
"refuse": {
2137+
"error": "type",
2138+
"names": "opens no app"
2139+
}
2140+
},
2141+
{
2142+
"name": "a-template-begins-with-its-scheme",
2143+
"why": "a browser drops leading spaces before reading a scheme, so a template that does not begin with one is refused",
2144+
"tools": "space-first",
2145+
"kind": "world",
2146+
"address": {
2147+
"form": "human",
2148+
"world": "0199c3a1-7b2e-7c3d-8e4f-5a6b7c8d9e0f"
2149+
},
2150+
"surface": {
2151+
"audience": "member",
2152+
"signed_in": true
2153+
},
2154+
"refuse": {
2155+
"error": "type",
2156+
"names": "begins with its scheme"
2157+
}
20302158
}
20312159
]
20322160
}

‎tests/test_openers.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
from onlyworlds import TOOLS, AddressError, openers_for, parse_ow_link
1515

1616
FIXTURE = Path(__file__).resolve().parent / "fixtures" / "openers.fixture.json"
17-
FIXTURE_SHA256 = "351ddec25f3af8cf8ec2c9c901d6ed4719355286467ada091e45d6012f8ed05b"
18-
CASES = 57
17+
FIXTURE_SHA256 = "0cbd1de0daa3535fbf36dcd502a611c6d960db827cfe88f5045f0a1a49d65ea0"
18+
CASES = 61
1919
WORLD = "0199c3a1-7b2e-7c3d-8e4f-5a6b7c8d9e0f"
2020
ELEMENT = "0199c3a1-7b2e-7c3d-8e4f-5a6b7c8d9e1a"
2121

0 commit comments

Comments
 (0)