Skip to content

form coral:接回 action=inbox,指向站自己的同源轉送路由 /__reef/inbox - #9

Merged
cverorg merged 1 commit into
mainfrom
feat/form-action-inbox
Sep 2, 2026
Merged

form coral:接回 action=inbox,指向站自己的同源轉送路由 /__reef/inbox#9
cverorg merged 1 commit into
mainfrom
feat/form-action-inbox

Conversation

@cverorg

@cverorg cverorg commented Sep 2, 2026

Copy link
Copy Markdown
Member

為什麼

action=inbox 8/15 撤回的原因是跨站 form POST 過不了 feelreef 的 CSRF。現在改成同源:表單送到站自己的 /__reef/inbox,站的 _worker.js 伺服端轉送(tile-lab 對應 PR)。

改動

  • Form.astro:action=inbox<form action="/__reef/inbox" method="post">(method 固定 post);hidden return_to(locale-aware 路徑)+ honeypot _hp(離屏、非 display:none);{email} 欄位命名 visitor_email,其他欄位保留站主標籤;與端點保留字撞名者加 field_ 前綴、標籤不變。
  • ?inbox=sent/其他:is:inline 小腳本切換伺服端預先渲染、預設隱藏的狀態句;文案走 uiCopy()(en-US/zh-TW/ja-JP/ko-KR)。
  • action=<url> 與未接線的 disabled 按鈕行為不變。🩸 區塊改寫為現行契約(2026-09-03)。
  • forms.md fixture+smoke-build 斷言(73/73);site-core/roundtrip/coral-params/chrome-copy 全綠。

同源轉發器(reef 那側平行在做的 `_worker.js` 轉發)已經有了,把 2026-08-15
撤掉的 `action=inbox` 接回來,這次接到的是真的會動的路由,不是直接打
feelreef.com 那個會被 SvelteKit 擋掉的版本。

Form.astro:
- `action=inbox` → `<form action="/__reef/inbox" method="post">`;`method=`
  對這個值無效,一律 post。
- 加兩個隱藏欄位:`return_to`(這頁自己的路徑,locale-aware,直接讀
  Astro.url.pathname)、蜜罐 `_hp`(視覺隱藏但不是 display:none,讓機器人
  照樣填得到;tabindex=-1 排除出 tab 順序)。
- 欄位命名:`{email}` 欄固定叫 `visitor_email`;其他欄位維持用擁有者寫的
  label 當 name,除非撞到轉發器的保留字(kind/id/text/conversation_id/
  page_url/return_to/_hp/visitor_email/email_field,不分大小寫比對)——
  撞到就在 wire name 前面加 `field_`,畫面上的 label 文字不變。
- `?inbox=sent` / `?inbox=<其他>` 的狀態列:用 lingo/locale.mjs 既有的
  uiCopy() 機制(Collection.astro 已經在用同一套)加 inboxSent/inboxError
  四語(en-US/zh-TW/ja-JP/ko-KR),伺服器端先算好、渲染成 hidden 的
  <p>,一段極小的 is:inline script 依 querystring 切換(跟 ArchiveView
  的 tag-filter script 同一種寫法,CSP-clean)。build 是 static 的,讀
  不到 query,所以這段只能是 client-side。
- `action=<url>`、未接線的 disabled 按鈕行為完全不動。

smoke-build.mjs + content/forms.md:forms.md 新增第三個 section(wired to
the reef inbox),把 email 欄跟一個故意撞保留字的 `### Text` 欄位都放進去;
smoke checks 新增 9 條斷言涵蓋 action 改寫、return_to/honeypot、
visitor_email、collision prefix、狀態列文字+hidden、script 只出現一次。
兩條舊斷言(zero-JS、unwired 沒有 action)改成用各自 form 的
起訖位置切,避免被新加的第三個 section 或每頁都有的 header-overlay
script 誤傷。66/66 綠燈。

by KITT
@cverorg
cverorg merged commit 6c3dcdd into main Sep 2, 2026
2 checks passed
cverorg added a commit that referenced this pull request Sep 3, 2026
…nbox 泡泡改帶 data-site-name(不再用頁面 title)、form action=inbox 的 email/訊息欄預設必填+原生驗證+在地化錯誤與送出後文案

- site-core.js:form 欄位語法新增 required/required: false 修飾詞,向下相容,序列化可還原
- Form.astro:required 欄位渲染原生 required + aria-required + 可見星號 + data-required-msg;
  action=inbox 對 email/textarea 欄位預設必填;成功文案依「email 是否保證有填」二選一,
  在地化表格獨立於既有四語 Lingo 表(locale.mjs 新增 inboxFormCopy,支援簡體 zh-Hans/zh-CN)
- SiteLayout.astro:inbox-bubble 掛載點加 data-site-name(沿用 header/footer 既有站名值)
- site.css:nav-mobile 開啟時的遮罩(沿用既有 rf-ha-overlay 原語)+ body 捲動鎖定
- 更新 smoke-build.mjs/forms.md fixture/site-core.test.js 的對應測試
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant