Skip to content

Entity: HTMLサニタイズNormalizerを追加#1969

Open
xtakahashi-hiroyuki wants to merge 12 commits intomasterfrom
feature/1892-sanitize-normalizer
Open

Entity: HTMLサニタイズNormalizerを追加#1969
xtakahashi-hiroyuki wants to merge 12 commits intomasterfrom
feature/1892-sanitize-normalizer

Conversation

@xtakahashi-hiroyuki
Copy link
Copy Markdown
Contributor

@xtakahashi-hiroyuki xtakahashi-hiroyuki commented Mar 3, 2026

対応内容

closes #1892

HTMLサニタイズNormalizerを標準Normalizerとして追加
SafeList APIを自由に使用できるようにする

仕様

  • 個別の設定項目(追加タグ、追加属性、追加プロトコル等)をそれぞれ定義として持つことはしない
  • プルダウン等でデフォルトの許可設定のSafelistオブジェクトを選択する
  • Groovyスクリプトで直接カスタマイズできる形にする

動作確認・スクリーンショット(任意)

2026-03-13_00h38_08

レビュー観点・補足情報(任意)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Entity のプロパティ正規化(Normalizer)に HTML サニタイズを追加し、RichText 等で入力された HTML から「許可タグ以外」を除去できるようにする変更です(Issue #1892 対応)。

Changes:

  • jsoup を依存関係に追加し、HTML クリーニング処理を実装
  • HtmlSanitizer(定義)/ MetaHtmlSanitize(実装)を追加し、NormalizerService に登録
  • 管理コンソール側に設定 UI(許可タグ入力)と文言(en/ja)を追加

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
sharedlibs.gradle jsoup バージョンを shared lib として追加
iplass-core/libs.gradle iplass-core の依存関係に jsoup を追加
iplass-core/src/main/java/org/iplass/mtp/impl/entity/normalizer/NormalizerService.java HtmlSanitizer → MetaHtmlSanitize のマッピングを追加
iplass-core/src/main/java/org/iplass/mtp/impl/entity/normalizer/MetaNormalizer.java JAXB の @XmlSeeAlso に MetaHtmlSanitize を追加
iplass-core/src/main/java/org/iplass/mtp/impl/entity/normalizer/MetaHtmlSanitize.java jsoup による HTML サニタイズ Runtime を実装(新規)
iplass-core/src/main/java/org/iplass/mtp/entity/definition/normalizers/HtmlSanitizer.java Normalizer 定義(許可タグ)を追加(新規)
iplass-core/src/main/java/org/iplass/mtp/entity/definition/NormalizerDefinition.java @XmlSeeAlso に HtmlSanitizer を追加
iplass-admin/src/main/resources/org/iplass/adminconsole/public/locale/locale_ja.js 設定 UI のホバー文言(ja)を追加
iplass-admin/src/main/resources/org/iplass/adminconsole/public/locale/locale_en.js 設定 UI のホバー文言(en)を追加
iplass-admin/src/main/java/org/iplass/adminconsole/client/metadata/ui/entity/property/normalizer/HtmlSanitizeAttributePane.java 許可タグ入力 UI を追加(新規)
iplass-admin/src/main/java/org/iplass/adminconsole/client/metadata/ui/entity/property/NormalizerListGridRecord.java NormalizerType に HTML Sanitizer を追加し UI で選択可能に

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

iplass-core/src/main/java/org/iplass/mtp/impl/entity/normalizer/NormalizerService.java:66

  • [must] map.get(n.getClass()).newInstance() は (1) 未登録の Normalizer が来た場合に NullPointerException になり原因特定が難しい、(2) Class#newInstance() は非推奨で例外情報も失われやすいです。map.get(...) の null チェックで分かりやすい IllegalArgumentException を投げ、インスタンス化は getDeclaredConstructor().newInstance() に置き換えてください。
	public MetaNormalizer createNormalizerMetaData(NormalizerDefinition n) {
		try {
			MetaNormalizer meta = map.get(n.getClass())
					.newInstance();
			meta.applyConfig(n);
			return meta;
		} catch (InstantiationException | IllegalAccessException e) {
			throw new IllegalArgumentException(e);

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

iplass-core/src/main/java/org/iplass/mtp/impl/entity/normalizer/NormalizerService.java:66

  • [must] map.get(n.getClass()) が未登録の場合に null.newInstance() となり NullPointerException が発生します(現状の catch では捕捉されません)。未対応の NormalizerDefinition が来た場合は、対応クラス名を含む IllegalArgumentException 等を明示的に投げるようにして、原因が追えるようにしてください。
	public MetaNormalizer createNormalizerMetaData(NormalizerDefinition n) {
		try {
			MetaNormalizer meta = map.get(n.getClass())
					.newInstance();
			meta.applyConfig(n);
			return meta;
		} catch (InstantiationException | IllegalAccessException e) {
			throw new IllegalArgumentException(e);

You can also share your feedback on Copilot code review. Take the survey.

@xtakahashi-hiroyuki xtakahashi-hiroyuki marked this pull request as ready for review March 16, 2026 03:36
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.

Entity: HTMLサニタイズNormalizerの提供

3 participants