From 3d32ea7c6121a80f4f3e2b41a04942ca8a58d784 Mon Sep 17 00:00:00 2001 From: Michael Buckingham Date: Tue, 2 Dec 2025 07:36:44 -0500 Subject: [PATCH] Fix onclick handlers breaking on source names with special chars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The |tojson filter outputs JSON with double quotes, which broke HTML attributes that also use double quotes. Added |e filter to HTML-escape the quotes to ", allowing names like "Kodiak Area Native Association (KANA)" to work correctly. Fixed in: - configure_source.html (3 showScrapeModal calls) - partials/generated_scraper.html (1 showScrapeModal call) - partials/source_list.html (1 openScrapeModal call) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- backend/app/templates/admin/configure_source.html | 6 +++--- backend/app/templates/admin/partials/generated_scraper.html | 2 +- backend/app/templates/admin/partials/source_list.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/app/templates/admin/configure_source.html b/backend/app/templates/admin/configure_source.html index 7e4ccd4..78aa93e 100644 --- a/backend/app/templates/admin/configure_source.html +++ b/backend/app/templates/admin/configure_source.html @@ -35,7 +35,7 @@

Configure Source + onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})"> @@ -76,7 +76,7 @@

+ onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})"> @@ -120,7 +120,7 @@

+ onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})"> diff --git a/backend/app/templates/admin/partials/generated_scraper.html b/backend/app/templates/admin/partials/generated_scraper.html index 674b77e..3261473 100644 --- a/backend/app/templates/admin/partials/generated_scraper.html +++ b/backend/app/templates/admin/partials/generated_scraper.html @@ -36,7 +36,7 @@

hx-post="/admin/sources/{{ source.id }}/scrape" hx-target="#scrape-modal-result" hx-swap="innerHTML" - onclick="showScrapeModal({{ source.name|tojson }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})" + onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})" class="w-full px-4 py-3 bg-purple-600 hover:bg-purple-700 text-white font-medium rounded-lg transition-colors flex items-center justify-center gap-2"> diff --git a/backend/app/templates/admin/partials/source_list.html b/backend/app/templates/admin/partials/source_list.html index 1ac1f5d..142b27d 100644 --- a/backend/app/templates/admin/partials/source_list.html +++ b/backend/app/templates/admin/partials/source_list.html @@ -197,7 +197,7 @@ hx-post="/admin/sources/{{ source.id }}/scrape" hx-target="#scrape-modal-result" hx-swap="innerHTML show:none" - onclick="openScrapeModal('{{ source.name }}')"> + onclick="openScrapeModal({{ source.name|tojson|e }})"> Scrape {% endif %}