From 178a9e6618e66b265c4f208ed61dd5b69a9ca39a Mon Sep 17 00:00:00 2001 From: Jarvis Date: Sun, 21 Sep 2025 07:40:39 +0200 Subject: [PATCH] security: fix innerHTML usage in settings to prevent XSS vulnerabilities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces innerHTML usage with Obsidian's safe DOM manipulation methods: - Line 150: Use createEl() and appendText() for commentary style display - Lines 159-168: Build usage instructions with createEl() instead of innerHTML This addresses the Obsidian Review Bot security warning and follows the official guidelines: https://docs.obsidian.md/Plugins/User+interface/HTML+elements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- settings.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/settings.ts b/settings.ts index c0df4b2..e1da8c3 100644 --- a/settings.ts +++ b/settings.ts @@ -147,7 +147,9 @@ export class FreewritingCleanupSettingTab extends PluginSettingTab { // Show the current preset for reference const presetText = COMMENTARY_PRESETS[this.plugin.settings.commentaryStyle as Exclude]; const descDiv = containerEl.createDiv({ cls: 'setting-item-description freewriting-cleanup-description' }); - descDiv.innerHTML = `Selected style: ${presetText}`; + descDiv.empty(); + descDiv.createEl('strong', { text: 'Selected style: ' }); + descDiv.appendText(presetText); } } @@ -156,16 +158,23 @@ export class FreewritingCleanupSettingTab extends PluginSettingTab { containerEl.createEl('h3', { text: 'Usage Information' }); const usageDiv = containerEl.createDiv(); - usageDiv.innerHTML = ` -

How to use:

-
    -
  1. Select the text you want to clean up in any note
  2. -
  3. Run the "Clean Up Freewriting" command (Ctrl/Cmd+P)
  4. -
  5. The cleaned text will appear below your original text
  6. -
-

Limits: Maximum 680,000 characters (~150,000 words) per cleanup

-

Format: Original text → separator → cleaned text

- `; + usageDiv.empty(); + + const howToUse = usageDiv.createEl('p'); + howToUse.createEl('strong', { text: 'How to use:' }); + + const list = usageDiv.createEl('ol'); + list.createEl('li', { text: 'Select the text you want to clean up in any note' }); + list.createEl('li', { text: 'Run the "Clean Up Freewriting" command (Ctrl/Cmd+P)' }); + list.createEl('li', { text: 'The cleaned text will appear below your original text' }); + + const limits = usageDiv.createEl('p'); + limits.createEl('strong', { text: 'Limits: ' }); + limits.appendText('Maximum 680,000 characters (~150,000 words) per cleanup'); + + const format = usageDiv.createEl('p'); + format.createEl('strong', { text: 'Format: ' }); + format.appendText('Original text → separator → cleaned text'); // MARK: - Reset Settings