From 672ad0db81e5e0443860b6d11bfc63982a11d5f2 Mon Sep 17 00:00:00 2001 From: LikC1606 Date: Tue, 1 Dec 2026 11:26:32 +0800 Subject: [PATCH 1/3] Remove hard-coded record count from archive pages The static "7 records" placeholder showed a wrong count until the catalog script ran. Leave it empty; app.ts fills in the real count. Co-Authored-By: Claude Opus 5.5 --- docs/archive.html | 2 +- docs/en/archive.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/archive.html b/docs/archive.html index d496e1d6..6fa1cbd2 100644 --- a/docs/archive.html +++ b/docs/archive.html @@ -91,7 +91,7 @@

TheoremOS 证明档案

题目 / 来源状态 / 更新
- + diff --git a/docs/en/archive.html b/docs/en/archive.html index 042a173a..e9322b36 100644 --- a/docs/en/archive.html +++ b/docs/en/archive.html @@ -91,7 +91,7 @@

TheoremOS Proof archive

Problem / sourceStatus / updated
- + From 9162a4db32c7cb51663383f6256d2e62c8f55b2b Mon Sep 17 00:00:00 2001 From: LikC1606 Date: Tue, 1 Dec 2026 12:29:04 +0800 Subject: [PATCH 2/3] Fix doubled periods in notices and log unexpected request errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Server error messages already end with a full stop, so templates such as '{0}。未提交内容已保留。' rendered "。。" (".." in English). A new clause() helper drops the message's closing punctuation before it is inserted. Unexpected errors in the request handler returned a generic 500 without any trace. They are now logged as [web_request_failed] with the method, the path without its query string, share tokens redacted, and the stack. Co-Authored-By: Claude Opus 5.5 --- apps/web/client/app.ts | 6 +++--- apps/web/client/sourceCheck.tsx | 4 ++-- apps/web/i18n.ts | 3 +++ apps/web/server.ts | 5 +++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/web/client/app.ts b/apps/web/client/app.ts index ef92cc5f..c33e408f 100644 --- a/apps/web/client/app.ts +++ b/apps/web/client/app.ts @@ -82,7 +82,7 @@ import { installTermHints, renderGlossary } from './termHints'; import { renderAdminPanel } from './ui/AdminPanel'; import { feedbackUrl, localizeSiteLinks } from './feedback'; import type { TermId } from './glossary'; -import { locale, localeTag, localizeMessage, localizeText, otherLocale, sentences, switchLocale, t } from '../i18n'; +import { clause, locale, localeTag, localizeMessage, localizeText, otherLocale, sentences, switchLocale, t } from '../i18n'; import { tx } from './researchShared'; import { historyStorageKey, markHistoryCollapsed, readHistoryCollapsed } from './historyPreference'; import { detailLevel, onDetailLevel } from './detailLevel'; @@ -2991,7 +2991,7 @@ async function poll(force = false) { catch (error) { if (!currentConnection(epoch)) return; if (sessionFailure(error)) { - disconnected(t('{0}。未提交内容已保留。', message(error))); + disconnected(t('{0}。未提交内容已保留。', clause(message(error)))); await initialize(); return; } @@ -3180,7 +3180,7 @@ function initialize(): Promise { setGlobalNotice(session.runtime.ready && session.providers.length ? '' : localizeText(session.runtime.message) || t('运行环境未就绪')); } catch (error) { if (currentConnection(epoch)) { - disconnected(t('{0}。未提交内容已保留。', message(error))); + disconnected(t('{0}。未提交内容已保留。', clause(message(error)))); if (!state.session) renderRunList(true); } } diff --git a/apps/web/client/sourceCheck.tsx b/apps/web/client/sourceCheck.tsx index f079a5f7..4ef7f637 100644 --- a/apps/web/client/sourceCheck.tsx +++ b/apps/web/client/sourceCheck.tsx @@ -1,7 +1,7 @@ import { render } from 'preact'; import type { WebEnvironment, WebPrecheck, WebPrecheckDiagnostic } from '../shared'; import { Icon, Spinner } from './ui/Icon'; -import { sentences, t } from '../i18n'; +import { clause, sentences, t } from '../i18n'; /** Structural findings carry a code; Lean's own diagnostics keep Lean's wording. */ const codeMessages: Record string> = { @@ -123,7 +123,7 @@ function summary(check: SourceCheck): { tone: Tone; title: string; detail: strin const { state } = check; if (state.phase === 'idle') return check.stale() ? { tone: 'neutral', title: t('源码已修改,稍后自动检查'), detail: '', chip: t('待检查') } : undefined; if (state.phase === 'checking') return { tone: 'busy', title: t('正在用 Lean 检查原题'), detail: t('引入 Mathlib 时首次检查约需半分钟。'), chip: t('检查中') }; - if (state.phase === 'failed') return { tone: 'warn', title: t('检查未完成'), detail: t('{0}。仍可提交。', state.message), chip: t('未检查') }; + if (state.phase === 'failed') return { tone: 'warn', title: t('检查未完成'), detail: t('{0}。仍可提交。', clause(state.message)), chip: t('未检查') }; if (check.stale()) return { tone: 'neutral', title: t('源码已修改,稍后自动检查'), detail: t('下方是修改前的检查结果。'), chip: t('待检查') }; const { result } = state; const errors = result.diagnostics.filter(item => item.severity === 'error').length; diff --git a/apps/web/i18n.ts b/apps/web/i18n.ts index 65a6cc4e..7eab6566 100644 --- a/apps/web/i18n.ts +++ b/apps/web/i18n.ts @@ -44,6 +44,9 @@ export const t = translator(locale); /** Joins translated sentences: Chinese runs them together after their 。, English needs a space between them. */ export const sentences = (...parts: string[]) => parts.filter(Boolean).join(locale === 'en' ? ' ' : ''); +/** Drops a message's closing punctuation so a template such as '{0}。…' can supply its own. */ +export const clause = (text: string) => text.replace(/[\s。..!!??]+$/u, ''); + const detail = /^(.*?)( · [^·]+)$/u; /** * Translates text produced elsewhere in Chinese, such as stored event messages and share labels, when it matches a key diff --git a/apps/web/server.ts b/apps/web/server.ts index c903f8b7..23db7333 100644 --- a/apps/web/server.ts +++ b/apps/web/server.ts @@ -1495,6 +1495,11 @@ export function createWebService(config: WebConfig, runner: WebRunner = new Dock { error: known ? error.message : invalidKnowledgeInput ? '知识查询或分页参数无效。' : '服务暂时不可用。', ...(error instanceof HttpError && error.code ? { code: error.code } : {}) }); else response.end(); + if (!known && !invalidKnowledgeInput) { + // The query string and share tokens stay out of the log. + const route = (request.url || '/').split('?')[0].replace(/^\/api\/share\/[^/]+/u, '/api/share/:token'); + console.error(`[web_request_failed] ${request.method} ${route}`, error instanceof Error ? error.stack ?? error.message : typeof error); + } } }); server.requestTimeout = 15_000; server.headersTimeout = 10_000; From fe0594d3a27d1838f3c8a884f0001ca225320ff7 Mon Sep 17 00:00:00 2001 From: LikC1606 Date: Tue, 1 Dec 2026 12:32:08 +0800 Subject: [PATCH 3/3] Reject malformed path escapes with 400 instead of 500 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A path such as /%E0%A4%A made decodeURIComponent throw a URIError in the static file handler and in API routes that decode their segments, which the server answered with 500. The request entry now checks the path once and answers 400 "访问地址无效。". Co-Authored-By: Claude Opus 5.5 --- apps/web/server.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/web/server.ts b/apps/web/server.ts index 23db7333..6a764f25 100644 --- a/apps/web/server.ts +++ b/apps/web/server.ts @@ -506,6 +506,8 @@ export function createWebService(config: WebConfig, runner: WebRunner = new Dock if (request.headers.origin && request.headers.origin !== origin.origin) throw new HttpError(403, '跨站请求已拒绝。'); const url = new URL(request.url || '/', origin); if (url.origin !== origin.origin) throw new HttpError(403, '访问地址无效。'); + // Routes decode path segments themselves; a malformed escape such as %E0%A4%A is the client's error, not a 500. + try { decodeURIComponent(url.pathname); } catch { throw new HttpError(400, '访问地址无效。'); } if (url.pathname.startsWith('/api/')) { prune(); // Behind a tunnel every request comes from the proxy, so the configured proxy header names the visitor.