From 1e73a2f8bf832428e1f7fdd4aa75aebfc2d2e488 Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 20 Aug 2019 22:44:11 +0200 Subject: [PATCH] Fix crash caused by "withheld" tweets --- src/parser.nim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parser.nim b/src/parser.nim index bda011a..acf0963 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -79,7 +79,8 @@ proc parseQuote*(quote: XmlNode): Quote = proc parseTweet*(node: XmlNode): Tweet = let tweet = node.select(".tweet") - if tweet == nil: return Tweet() + if tweet == nil or "withheld-tweet" in tweet.attr("class"): + return Tweet() result = Tweet( id: tweet.attr("data-item-id"), @@ -119,7 +120,7 @@ proc parseThread*(nodes: XmlNode): Thread = result = Thread() for n in nodes.filterIt(it.kind != xnText): let class = n.attr("class").toLower() - if "tombstone" in class or "unavailable" in class: + if "tombstone" in class or "unavailable" in class or "withheld" in class: result.tweets.add Tweet() elif "morereplies" in class: result.more = getMoreReplies(n)