Files
kevin 2f7f322b62 fix(web): Quill 编辑器本地化,修复写邮件页无法输入正文
- 修复 3f28ec2 引入的回归:CSP script-src/style-src 'self' 拦截了
  CDN 的 quill.min.js / quill.snow.css,编辑器初始化失败导致正文不可输入
- 下载 Quill 1.3.7 到 internal/web/static/vendor/quill/(.gitignore 加例外)
- 新增 /static 静态路由,compose 模板改为同源加载:CSP 保持严格,
  且服务器离线可用、摆脱第三方 CDN 依赖
- 新增 static_test.go 回归测试验证静态资源可访问
2026-08-20 01:37:42 +08:00

41 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package web
// 回归测试:写邮件页的 Quill 编辑器必须由本服务同源提供静态资源
// CSP script-src/style-src 'self' 会拦截外部 CDN),否则正文无法输入。
import (
"io"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestQuillAssetsServedLocally(t *testing.T) {
ws, _ := newTestWebServer(t, "0123456789abcdef0123456789abcdef")
srv := httptest.NewServer(ws.Handler())
defer srv.Close()
for _, path := range []string{
"/static/vendor/quill/quill.min.js",
"/static/vendor/quill/quill.snow.css",
} {
resp, err := http.Get(srv.URL + path)
if err != nil {
t.Fatalf("GET %s: %v", path, err)
}
body, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if resp.StatusCode != http.StatusOK {
t.Fatalf("GET %s status = %d, want 200", path, resp.StatusCode)
}
if len(body) < 1000 {
t.Fatalf("GET %s body too small (%d bytes), vendor file missing?", path, len(body))
}
if strings.HasPrefix(path, "/static/vendor/quill/quill.min.js") &&
!strings.Contains(string(body), "Quill") {
t.Fatalf("%s 不是 Quill 脚本", path)
}
}
}