Skip to content

Commit 930dcd0

Browse files
Fix onclick handlers breaking on source names with special chars (#107)
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 &quot;, 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 <noreply@anthropic.com>
1 parent e23256b commit 930dcd0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

backend/app/templates/admin/configure_source.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ <h2 class="text-2xl font-bold text-gray-900 dark:text-white">Configure Source</h
3535
hx-post="/admin/sources/{{ source.id }}/scrape"
3636
hx-target="#scrape-modal-result"
3737
hx-swap="innerHTML"
38-
onclick="showScrapeModal({{ source.name|tojson }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})">
38+
onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})">
3939
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
4040
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
4141
</svg>
@@ -76,7 +76,7 @@ <h3 class="text-lg font-semibold text-green-800 dark:text-green-200 flex items-c
7676
hx-post="/admin/sources/{{ source.id }}/scrape"
7777
hx-target="#scrape-modal-result"
7878
hx-swap="innerHTML"
79-
onclick="showScrapeModal({{ source.name|tojson }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})">
79+
onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})">
8080
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
8181
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"></path>
8282
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
@@ -120,7 +120,7 @@ <h3 class="text-lg font-semibold text-blue-800 dark:text-blue-200 flex items-cen
120120
hx-post="/admin/sources/{{ source.id }}/scrape"
121121
hx-target="#scrape-modal-result"
122122
hx-swap="innerHTML"
123-
onclick="showScrapeModal({{ source.name|tojson }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})">
123+
onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})">
124124
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
125125
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"></path>
126126
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>

backend/app/templates/admin/partials/generated_scraper.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ <h3 class="text-lg font-semibold dark:text-white flex items-center gap-2">
3636
hx-post="/admin/sources/{{ source.id }}/scrape"
3737
hx-target="#scrape-modal-result"
3838
hx-swap="innerHTML"
39-
onclick="showScrapeModal({{ source.name|tojson }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})"
39+
onclick="showScrapeModal({{ source.name|tojson|e }}, {{ 'true' if source.use_playwright or source.use_playwright is none else 'false' }})"
4040
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">
4141
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
4242
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"></path>

backend/app/templates/admin/partials/source_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
hx-post="/admin/sources/{{ source.id }}/scrape"
198198
hx-target="#scrape-modal-result"
199199
hx-swap="innerHTML show:none"
200-
onclick="openScrapeModal('{{ source.name }}')">
200+
onclick="openScrapeModal({{ source.name|tojson|e }})">
201201
Scrape
202202
</button>
203203
{% endif %}

0 commit comments

Comments
 (0)