Skip to content

Commit ceb8df6

Browse files
committed
fix(pkce): tolerate redirectUri slash; tweak zh labels
1 parent 3e81749 commit ceb8df6

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

app/src/lib/i18n/locales/zh-CN.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const zhCN = {
4747
weekendDesc: '默认隐藏周六日,如有周末课程或需展示可开启。',
4848
weekendOn: '显示周末',
4949
weekendOff: '隐藏周末',
50-
languageLabel: '界面语言',
50+
languageLabel: '语言',
5151
languageDesc: '切换 UI 语言,立刻生效。',
5252
languageOptions: {
5353
auto: '自动(跟随系统/插件)',
@@ -926,7 +926,7 @@ export const zhCN = {
926926
currentTerm: '当前学期:{term}',
927927
storageTitle: '当前设置快照',
928928
storageDescription: '以下是当前浏览器存储的偏好设置,供参考或调试。',
929-
storageLanguage: '界面语言:{locale}',
929+
storageLanguage: '语言:{locale}',
930930
storageTheme: '主题:{theme}',
931931
storagePagination: '分页:{mode},每页 {size} 条,邻近 {neighbors} 页',
932932
storageSelectionMode: '选课模式:{mode}',
@@ -1186,7 +1186,7 @@ export const zhCN = {
11861186
progress: '步骤 {current}/{total}',
11871187
termLabel: '学期:{term}',
11881188
language: {
1189-
body: '请选择界面语言。',
1189+
body: '请选择语言。',
11901190
hint: '选择“自动”会跟随系统语言。你也可以在设置中随时修改。',
11911191
options: {
11921192
auto: '自动',

app/src/lib/policies/github/oauthPkce.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ function getOauthProxyUrl() {
3131
}
3232
}
3333

34+
function normalizeRedirectUri(value: string) {
35+
try {
36+
const url = new URL(value);
37+
url.hash = '';
38+
url.search = '';
39+
const pathname = url.pathname.replace(/\/+$/, '');
40+
return `${url.origin}${pathname}`;
41+
} catch {
42+
return String(value || '').replace(/\/+$/, '');
43+
}
44+
}
45+
3446
export function getGithubPkceAvailability(): GithubPkceAvailability {
3547
if (!browser) return { supported: false, reason: 'unsupportedRuntime' };
3648
const clientId = publicEnv.PUBLIC_GITHUB_CLIENT_ID;
@@ -147,7 +159,7 @@ export async function completeGithubPkceCallback(url: URL): Promise<GithubPkceCa
147159

148160
const availability = getGithubPkceAvailability();
149161
if (!availability.supported) return { ok: false, errorKey: 'errors.githubPkceUnsupported' };
150-
if (availability.redirectUri !== session.redirectUri) {
162+
if (normalizeRedirectUri(availability.redirectUri) !== normalizeRedirectUri(session.redirectUri)) {
151163
return { ok: false, errorKey: 'errors.githubStateValidation' };
152164
}
153165

0 commit comments

Comments
 (0)