Skip to content

Commit

Permalink
Fix issue #617 by using mark_safe in combination with format_html
Browse files Browse the repository at this point in the history
I have no experience with Django, so all I'm really going off of is this
stackoverflow

https://stackoverflow.com/a/64498319

which cited this bit of Django documentation:

https://docs.djangoproject.com/en/3.1/ref/utils/#django.utils.html.format_html

After using this method, I no longer get the 500 error or KeyError
exception, and can browse the local server and interact with the single
entry in it (the problematic URL in #617 with curly braces).

Whether this is the "right" method or not, I have no idea. But it is at
least a start.
  • Loading branch information
aspensmonster committed Jan 24, 2021
1 parent c6f0b8e commit 1989275
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions archivebox/index/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Optional, Iterator, Mapping
from pathlib import Path

from django.utils.html import format_html
from django.utils.html import format_html, mark_safe
from collections import defaultdict

from .schema import Link
Expand Down Expand Up @@ -161,4 +161,4 @@ def snapshot_icons(snapshot) -> str:
output += '<a href="{}" class="exists-{}" title="{}">{}</a> '.format(canon["archive_org_path"], str(exists),
"archive_org", icons.get("archive_org", "?"))

return format_html(f'<span class="files-icons" style="font-size: 1.1em; opacity: 0.8">{output}<span>')
return format_html('<span class="files-icons" style="font-size: 1.1em; opacity: 0.8">{}<span>', mark_safe(output))

0 comments on commit 1989275

Please sign in to comment.