MTG / freesound

The Freesound website
https://freesound.org
GNU Affero General Public License v3.0
317 stars 88 forks source link

KeyError: 'src' #1112

Closed ffont closed 6 years ago

ffont commented 6 years ago

https://logserver.mtg.upf.edu/sentry/freesound-web/issues/1022/

KeyError: 'src'
(34 additional frame(s) were not displayed)
...
  File "utils/username.py", line 64, in inner
    return func(request, *args, **kwargs)
  File "accounts/views.py", line 840, in account
    return render(request, 'accounts/account.html', tvars)
  File "general/templatetags/filter_img.py", line 14, in replace_img
    if not img['src'].lower().startswith("https"):

KeyError: 'src'

I thought we were not using BeautifulSoup anywhere now, but I guess we only replaced in some places?

alastair commented 6 years ago

This is the template tag which converts http to https links. We should

alastair commented 6 years ago

Bleach/html5lib has filters (https://bleach.readthedocs.io/en/latest/clean.html#html5lib-filters-filters), which might do what we want, but I'm not sure how complex it would be to force it to rewrite an img tag to an a tag. I already like the simplicity of the current beautiful soup filter, so I would only use a bleach filter if we can make it look as nice and understandable.