@celestia-island/hikari 0.55.474 → 0.55.476
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/components/loginDiscovery.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/loginDiscovery.test.ts +19 -0
- package/src/components/loginDiscovery.ts +18 -3
- package/src/styles/admin-tokens.scss +6 -0
- package/src/wasm/highlight/hikari_wasm_highlight.js +1 -1
- package/src/wasm/mermaid/hikari_wasm_mermaid.js +1 -1
- package/src/wasm/qr/hikari_wasm_qr.js +1 -1
|
@@ -78,8 +78,9 @@ export interface HkLoginPlanCopy {
|
|
|
78
78
|
*/
|
|
79
79
|
export declare function hkLoginPlanFromDiscovery(d: HkLoginDiscovery, copy?: HkLoginPlanCopy): HkLoginPlan;
|
|
80
80
|
/** True for a path hikari may forward as a return address: absolute,
|
|
81
|
-
* same-origin by construction (`/x`),
|
|
82
|
-
* (`//evil.example`)
|
|
81
|
+
* same-origin by construction (`/x`), not a protocol-relative URL
|
|
82
|
+
* (`//evil.example`), not the bare root, and free of backslashes, control
|
|
83
|
+
* and format characters (see `UNSAFE_IN_A_LOCATION`). */
|
|
83
84
|
export declare function hkIsSameOriginPath(raw: string): boolean;
|
|
84
85
|
/**
|
|
85
86
|
* The navigation target of a relay entry, or `null` when the document is
|
package/package.json
CHANGED
|
@@ -142,6 +142,25 @@ describe("hkIsSameOriginPath", () => {
|
|
|
142
142
|
expect(hkIsSameOriginPath("https://evil.example")).toBe(false);
|
|
143
143
|
expect(hkIsSameOriginPath("console")).toBe(false);
|
|
144
144
|
expect(hkIsSameOriginPath("")).toBe(false);
|
|
145
|
+
// MUT:no-backslash — a path with a backslash (browsers turn `/\host`
|
|
146
|
+
// into `//host`), a control character (C0, DEL and the C1 range), a
|
|
147
|
+
// line separator or a display-reshaping format character never passes,
|
|
148
|
+
// because the value ends up in a `Location` header; an internationalised
|
|
149
|
+
// path always does. The same rule as kirino's navigation-target check.
|
|
150
|
+
for (const bad of [
|
|
151
|
+
"/\\evil.example/x",
|
|
152
|
+
"/\nevil",
|
|
153
|
+
"/in\u{007f}box",
|
|
154
|
+
"/\u{2028}x",
|
|
155
|
+
"/in\u{200b}box",
|
|
156
|
+
"/\u{202e}xp",
|
|
157
|
+
"/in\u{feff}box",
|
|
158
|
+
]) {
|
|
159
|
+
expect(hkIsSameOriginPath(bad)).toBe(false);
|
|
160
|
+
}
|
|
161
|
+
// Internationalised paths are untouched by the rule.
|
|
162
|
+
expect(hkIsSameOriginPath("/收件箱")).toBe(true);
|
|
163
|
+
expect(hkIsSameOriginPath("/café/x?y=日本語")).toBe(true);
|
|
145
164
|
});
|
|
146
165
|
});
|
|
147
166
|
|
|
@@ -134,11 +134,26 @@ export function hkLoginPlanFromDiscovery(
|
|
|
134
134
|
return { mode: d.mode, channels: [channel], defaultChannel: key };
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/** Characters a navigation target must never contain. A backslash is read
|
|
138
|
+
* as a slash by browsers, so `/` + backslash + host leaves the origin;
|
|
139
|
+
* control characters, the line/paragraph separators and the format
|
|
140
|
+
* characters that reshape how a path is displayed or ordered (soft hyphen,
|
|
141
|
+
* zero-width marks, bidi controls, BOM) are refused because the value ends
|
|
142
|
+
* up in a `Location` header and may be shown to a user. The same rule as
|
|
143
|
+
* kirino's `relay::is_unsafe_in_a_location`; keep the two in step. */
|
|
144
|
+
const UNSAFE_IN_A_LOCATION = /[\u0000-\u001f\u007f-\u009f\u2028\u2029\u00ad\u200b-\u200f\u202a-\u202e\u2066-\u2069\ufeff\\]/;
|
|
145
|
+
|
|
137
146
|
/** True for a path hikari may forward as a return address: absolute,
|
|
138
|
-
* same-origin by construction (`/x`),
|
|
139
|
-
* (`//evil.example`)
|
|
147
|
+
* same-origin by construction (`/x`), not a protocol-relative URL
|
|
148
|
+
* (`//evil.example`), not the bare root, and free of backslashes, control
|
|
149
|
+
* and format characters (see `UNSAFE_IN_A_LOCATION`). */
|
|
140
150
|
export function hkIsSameOriginPath(raw: string): boolean {
|
|
141
|
-
return
|
|
151
|
+
return (
|
|
152
|
+
raw.startsWith("/") &&
|
|
153
|
+
!raw.startsWith("//") &&
|
|
154
|
+
raw !== "/" &&
|
|
155
|
+
!UNSAFE_IN_A_LOCATION.test(raw)
|
|
156
|
+
);
|
|
142
157
|
}
|
|
143
158
|
|
|
144
159
|
/**
|
|
@@ -1207,6 +1207,12 @@
|
|
|
1207
1207
|
.s-auth-card-height {
|
|
1208
1208
|
transition: none;
|
|
1209
1209
|
}
|
|
1210
|
+
// The frame's one-shot entrance is motion (16px translate + 0.92 scale),
|
|
1211
|
+
// not just opacity: reduced motion drops it outright. The sibling
|
|
1212
|
+
// height transition above is a resize follow, which stays.
|
|
1213
|
+
.s-auth-card {
|
|
1214
|
+
animation: none;
|
|
1215
|
+
}
|
|
1210
1216
|
}
|
|
1211
1217
|
|
|
1212
1218
|
.s-auth-card input:not(.hk-otp-cell) {
|