fix(automation): strip HTML comments before metadata extraction#40
Merged
Conversation
TITLE_RE / META_DESC_RE / SECTION_RE は src の HTML 全体に対して走るので、 HTML コメント内に literal の <title> や <meta name="description"> 文字列が 書かれていると、コメントの開きタグから本物の </title> までを誤キャプチャ してしまっていた。 実例: _template/index.html のコメントは「<title> と <meta name=description> は自動転記される」と書いていたため、テンプレートからコピーした全 lecture が validate_metadata の改行検査で SystemExit する地雷を踏んでいた。 修正: - strip_html_comments() を抽出前に通し、コメント内のタグ風文字列を無視する - _template/index.html のコメントから literal の <title>/<meta> 記述を除去 (defense in depth: regex 修正と併用) E2E 検証: 修正前 fail → 修正後 5 ブロック正常検知。コメント内に攻撃的な <title>FAKE</title> を仕込んでも本物の title/desc が正しく抽出される。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/sync_listings.pyの TITLE_RE / META_DESC_RE / SECTION_RE が HTML コメント内に書かれた literal の<title>や<meta name="description">に誤マッチしていた。_template/index.htmlのコメントに自動同期の説明として literal の<title>を含めていたため、テンプレートからコピーした全 lecture が改行 forbidden エラーで fail する地雷だった。Related Issue
No-Issue: PR #36 (auto-listings 導入) の E2E 検証で発覚した既知バグの即時修正。issue 化するより直す方が早い小規模 fix。
Changes
scripts/sync_listings.py— 抽出前にstrip_html_comments()を通してコメントを除去_template/index.html— コメントから literal の<title>/<meta name=description>記述を除去(regex 修正との二重防衛)Test plan
<title>FAKE TITLE</title>を仕込んでも、本物の title/desc が正しく抽出される_template/からコピーした lecture が問題なく追加できるDiscovery context
PR #36 マージ直後の E2E テストで
cp -r _template 99-fake-testで fake lecture を作って--checkを回した時に発見。safety net (validate_metadata の改行検査) が exit 1 で fail させたので被害ゼロだったが、エラーメッセージが原因を直接示さず、_template/を使う全コントリビュータが踏む地雷だった。🤖 Generated with Claude Code