security: fix innerHTML usage in settings to prevent XSS vulnerabilities
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 <noreply@anthropic.com>
This commit is contained in:
1 file changed
+20
-11
+20
-11
@@ -147,7 +147,9 @@ export class FreewritingCleanupSettingTab extends PluginSettingTab {
|
|||||||
// Show the current preset for reference
|
// Show the current preset for reference
|
||||||
const presetText = COMMENTARY_PRESETS[this.plugin.settings.commentaryStyle as Exclude<CommentaryStyle, 'custom'>];
|
const presetText = COMMENTARY_PRESETS[this.plugin.settings.commentaryStyle as Exclude<CommentaryStyle, 'custom'>];
|
||||||
const descDiv = containerEl.createDiv({ cls: 'setting-item-description freewriting-cleanup-description' });
|
const descDiv = containerEl.createDiv({ cls: 'setting-item-description freewriting-cleanup-description' });
|
||||||
descDiv.innerHTML = `<strong>Selected style:</strong> ${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' });
|
containerEl.createEl('h3', { text: 'Usage Information' });
|
||||||
|
|
||||||
const usageDiv = containerEl.createDiv();
|
const usageDiv = containerEl.createDiv();
|
||||||
usageDiv.innerHTML = `
|
usageDiv.empty();
|
||||||
<p><strong>How to use:</strong></p>
|
|
||||||
<ol>
|
const howToUse = usageDiv.createEl('p');
|
||||||
<li>Select the text you want to clean up in any note</li>
|
howToUse.createEl('strong', { text: 'How to use:' });
|
||||||
<li>Run the "Clean Up Freewriting" command (Ctrl/Cmd+P)</li>
|
|
||||||
<li>The cleaned text will appear below your original text</li>
|
const list = usageDiv.createEl('ol');
|
||||||
</ol>
|
list.createEl('li', { text: 'Select the text you want to clean up in any note' });
|
||||||
<p><strong>Limits:</strong> Maximum 680,000 characters (~150,000 words) per cleanup</p>
|
list.createEl('li', { text: 'Run the "Clean Up Freewriting" command (Ctrl/Cmd+P)' });
|
||||||
<p><strong>Format:</strong> Original text → separator → cleaned text</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
|
// MARK: - Reset Settings
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user