release: v1.2.2 — 双域名配置与 Host 隔离修复
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s

修复设置页误清空管理域、配置与生效 URL 混淆及第三 Host 绕过隔离;加固 Settings API 与中间件,并更新文档站。
This commit is contained in:
O96u committed 2026-08-30 10:57:26 +08:00
1 parent 6c6766221b
commit c9c34515dd
36 files changed
+2578 -180

No files matched your search

+30 -4
View File
@@ -2,13 +2,16 @@ import { describe, expect, it } from 'vitest'
import {
isBareImageFilename,
isHiddenImageDatePath,
toPublicImagePath
storageKeyToPublicPath,
toPublicImagePath,
toStorageKeyFromPublicPath
} from './image-public-path'
describe('toPublicImagePath', () => {
it('returns key unchanged when hideFolder is false', () => {
expect(toPublicImagePath('images/2026/08/a.webp', false)).toBe('images/2026/08/a.webp')
expect(toPublicImagePath('images/a.webp', false)).toBe('images/a.webp')
it('strips internal images/ prefix when hideFolder is false', () => {
expect(toPublicImagePath('images/2026/08/a.webp', false)).toBe('2026/08/a.webp')
expect(toPublicImagePath('images/a.webp', false)).toBe('a.webp')
expect(toPublicImagePath('images/blog/a.webp', false)).toBe('blog/a.webp')
})
it('returns basename when hideFolder is true', () => {
@@ -18,6 +21,29 @@ describe('toPublicImagePath', () => {
})
})
describe('storageKeyToPublicPath', () => {
it('removes images/ prefix only', () => {
expect(storageKeyToPublicPath('images/2026/08/a.webp')).toBe('2026/08/a.webp')
})
})
describe('toStorageKeyFromPublicPath', () => {
it('maps public relative paths to storage keys', () => {
expect(toStorageKeyFromPublicPath('2026/08/a.webp')).toBe('images/2026/08/a.webp')
expect(toStorageKeyFromPublicPath('blog/a.webp')).toBe('images/blog/a.webp')
expect(toStorageKeyFromPublicPath('a.webp')).toBe('images/a.webp')
})
it('accepts legacy full storage keys', () => {
expect(toStorageKeyFromPublicPath('images/2026/08/a.webp')).toBe('images/2026/08/a.webp')
})
it('rejects invalid paths', () => {
expect(toStorageKeyFromPublicPath('')).toBeNull()
expect(toStorageKeyFromPublicPath('../../../etc/passwd')).toBeNull()
})
})
describe('isHiddenImageDatePath', () => {
it('accepts YYYY/MM/file paths', () => {
expect(isHiddenImageDatePath('2026/08/demo.webp')).toBe(true)