fix(quoted-text): Guard call to children[0] Sentry 33642

This commit is contained in:
Ben Gotow 2016-04-26 14:12:57 -07:00
parent 1fcef30b6b
commit 76ccfce39b

View file

@ -52,6 +52,8 @@ class QuotedHTMLTransformer
@removeTrailingBr(doc) @removeTrailingBr(doc)
DOMUtils.Mutating.removeElements(quoteStringDetector(doc)) DOMUtils.Mutating.removeElements(quoteStringDetector(doc))
return "<head></head><body></body>" unless doc.children[0]
return doc.children[0].innerHTML return doc.children[0].innerHTML
# Finds any trailing BR tags and removes them in place # Finds any trailing BR tags and removes them in place
@ -88,6 +90,9 @@ class QuotedHTMLTransformer
text = "HTML Parser Error: #{error.toString()}" text = "HTML Parser Error: #{error.toString()}"
doc = domParser.parseFromString(text, "text/html") doc = domParser.parseFromString(text, "text/html")
NylasEnv.reportError(error) NylasEnv.reportError(error)
# As far as we can tell, when this succeeds, doc /always/ has at least
# one child: an <html> node.
return doc return doc
_wholeBodyIsQuote: (doc, quoteElements) -> _wholeBodyIsQuote: (doc, quoteElements) ->