Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors in preview cause django traceback #16

Open
drnlm opened this issue Jul 1, 2021 · 0 comments
Open

Errors in preview cause django traceback #16

drnlm opened this issue Jul 1, 2021 · 0 comments

Comments

@drnlm
Copy link
Member

drnlm commented Jul 1, 2021

As seen in the za.pycon.org error logs:

File "<ve>/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "<ve>/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "<ve>/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "<ve>/site-packages/markitup/views.py" in apply_filter
  10.     markup = filter_func(request.POST.get('data', ''))

File "<ve>/site-packages/markdown/core.py" in markdown
  387.     return md.convert(text)

File "<ve>/site-packages/markdown/core.py" in convert
  261.             self.lines = prep.run(self.lines)

File "<ve>/site-packages/markdown/preprocessors.py" in run
  81.         parser.close()

File "<ve>/site-packages/markdown/htmlparser.py" in close
  78.         super().close()

File "/usr/lib/python3.8/html/parser.py" in close
  115.         self.goahead(1)

File "/usr/lib/python3.8/html/parser.py" in goahead
  173.                     k = self.parse_endtag(i)

File "/usr/lib/python3.8/html/parser.py" in parse_endtag
  421.         self.handle_endtag(elem)

File "<ve>/site-packages/markdown/htmlparser.py" in handle_endtag
  148.         text = self.get_endtag_text(tag)

File "<ve>/site-packages/markdown/htmlparser.py" in get_endtag_text
  118.         start = self.line_offset + self.offset

File "<ve>/site-packages/markdown/htmlparser.py" in line_offset
  95.             return re.match(r'([^\n]*\n){{{}}}'.format(self.lineno-1), self.rawdata).end()

Exception Type: AttributeError at /markitup/preview/
Exception Value: 'NoneType' object has no attribute 'end'

While we can't do much about malformed input, we really should handle errors during preview better, and provide some other form of feedback if this happens, and only span the logs if invalid input is actually submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant