harvard-lil / h2o

H2O is a web app for creating and reading open educational resources, primarily in the legal field
https://opencasebook.org
GNU Affero General Public License v3.0
36 stars 30 forks source link

Unclosed tag is causing reading length calculation to fail #1922

Closed sentry-io[bot] closed 1 year ago

sentry-io[bot] commented 1 year ago

Some problem parsing this content causes the SAX parser used for docx export to throw an exception.

This particular code is also used by the function that calculates total reading duration, so this has a much nastier effect of making the section itself inaccessible.

To fix this:

h/t @bensteinberg for bringing this to my attention

Sentry Issue: H2O-9D

TypeError: 'ContentNode' object is not subscriptable
  File "django/template/base.py", line 829, in _resolve_lookup
    current = current[bit]

SaxError: Unexpected element closed: a
(47 additional frame(s) were not displayed)
...
  File "main/models.py", line 2715, in calculate_reading_length
    html_out = annotated_content_for_export(self)
  File "main/export.py", line 272, in annotated_content_for_export
    dest_tree = handler.get_output_tree()
  File "main/export.py", line 239, in get_output_tree
    method(*args)
  File "src/lxml/sax.py", line 144, in lxml.sax.ElementTreeContentHandler.endElement
  File "src/lxml/sax.py", line 134, in lxml.sax.ElementTreeContentHandler.endElementNS