barisusakli / nodebb-plugin-rss

A NodeBB Plugin to post topics using RSS feeds
28 stars 23 forks source link

TypeError: Cannot read property '1' of null #9

Closed aggied closed 9 years ago

aggied commented 9 years ago

While pulling in a google news RSS feed https://news.google.com/?q=elections&output=rss I get the following error. Not sure yet what the cause is. Do we blame the to-markdown library? Or is the plugin sending in bad markdown?

11/7 15:13 [1307] - error: TypeError: Cannot read property '1' of null
    at ELEMENTS.replacement (/home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:75:70)
    at /home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:100:41
    at String.replace (native)
    at replaceEls (/home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:99:23)
    at toMarkdown (/home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:82:16)
    at /home/lififorums/nodebb/node_modules/nodebb-plugin-rss/index.js:202:14
    at /home/lififorums/nodebb/src/database/mongo/sorted.js:325:4
    at handleCallback (/home/lififorums/nodebb/node_modules/mongodb/lib/utils.js:95:12)
    at /home/lififorums/nodebb/node_modules/mongodb/lib/collection.js:1064:5
    at handleCallback (/home/lififorums/nodebb/node_modules/mongodb/lib/utils.js:95:12)
TypeError: Cannot read property '1' of null
    at ELEMENTS.replacement (/home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:75:70)
    at /home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:100:41
    at String.replace (native)
    at replaceEls (/home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:99:23)
    at toMarkdown (/home/lififorums/nodebb/node_modules/nodebb-plugin-rss/node_modules/to-markdown/src/to-markdown.js:82:16)
    at /home/lififorums/nodebb/node_modules/nodebb-plugin-rss/index.js:202:14
    at /home/lififorums/nodebb/src/database/mongo/sorted.js:325:4
    at handleCallback (/home/lififorums/nodebb/node_modules/mongodb/lib/utils.js:95:12)
    at /home/lififorums/nodebb/node_modules/mongodb/lib/collection.js:1064:5
    at handleCallback (/home/lififorums/nodebb/node_modules/mongodb/lib/utils.js:95:12)
aggied commented 9 years ago

Doing a little digging, I decided to add console.log(content); to https://github.com/barisusakli/nodebb-plugin-rss/blob/master/index.js#L201 and this is what I got. So there is indeed content going in, but it seems the RSS is invalid? I'll keep digging.

<table border="0" cellpadding="2" cellspacing="7" style="vertical-align:top"><tr><td width="80" align="center" valign="top"><font style="font-size:85%;font-family:arial,sans-serif"><a href="http://news.google.com/news/url?sa=t&amp;fd=R&amp;ct2=us&amp;usg=AFQjCNEqrwlccLXfzsTyGlI4f-23ZJBS4Q&amp;clid=c3a7d30bb8a4878e06b80cf16b898331&amp;ei=ZGihVeiJKYKQ3QGLloAQ&amp;url=http://www.infosecurity-magazine.com/blogs/li-fi-fantastic/"><img src="//t0.gstatic.com/images?q=tbn:ANd9GcShnW8tGFMA1NgYfNF1SkvnN_UasT-JegBSw1Ei6nb5bGU-ku-cUY6pY9Yig7xlg1BJwicybZJ0" alt="" border="1" width="80" height="80"><br><font size="-2">Infosecurity Magazine (blog)</font></a></font></td><td valign="top"><font style="font-size:85%;font-family:arial,sans-serif"><br><img alt="" height="1" width="1"><a href="http://news.google.com/news/url?sa=t&amp;fd=R&amp;ct2=us&amp;usg=AFQjCNEqrwlccLXfzsTyGlI4f-23ZJBS4Q&amp;clid=c3a7d30bb8a4878e06b80cf16b898331&amp;ei=ZGihVeiJKYKQ3QGLloAQ&amp;url=http://www.infosecurity-magazine.com/blogs/li-fi-fantastic/"><b><b>Li-Fi</b> fantastic – Quocirca&#39;s Report from Infosec 2015</b></a><br><font size="-1"><b><font color="#6f6f6f">Infosecurity Magazine (blog)</font></b></font><br><font size="-1">As with any trade show, Infosecurity Europe (the continent&#39;s biggest IT security bash) can get a bit mind-numbing, with one vendor after another going on about the big issues of the day – advanced threat detection, threat intelligence networks, the <b>...</b></font><br><font size="-1"></font><br><font size="-1"><a href="http://news.google.com/news/more?ncl=dFWDTPidOBmbn9M&amp;authuser=0&amp;ned=us"><b></b></a></font></font></td></tr></table>
aggied commented 9 years ago

Nothing wrong with the plugin per se, but it is relying on a deprecated service in Google's Feed API. The API is unable to process custom google news feeds. Considering a fork that removes the Google News dependency.

barisusakli commented 9 years ago

If there is content going in like you said it looks like toMarkdown is crashing did you post on their repo?

barisusakli commented 9 years ago

I should update the tomarkdown dependency in this plugin its ancient at 0.0.2

aggied commented 8 years ago

haven't had a chance to update -- will do soon. thanks