While doing some tests with unfurl I stumble upon Soundcloud XML implementation which was only partially working.
Looking at their XML it seems that they are escaping their html node with CDATA which is not unreasonable to be fair:
<oembed>
<version type="float">1.0</version>
<type>rich</type>
<provider-name>SoundCloud</provider-name>
<provider-url>https://soundcloud.com</provider-url>
<height type="integer">400</height>
<width>100%</width>
<title>Bugle 179 - Playas gon play by The Bugle</title>
<description>This week - oh PIPA, Republican't candidates and Craptain Italia. Remember to #savethebugle at http://www.thebuglepodcast.com</description>
<thumbnail-url>https://i1.sndcdn.com/artworks-000017079411-pgm0ii-t500x500.jpg</thumbnail-url>
<html><![CDATA[<iframe width="100%" height="400" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F34019569&show_artwork=true"></iframe>]]></html>
<author-name>The Bugle</author-name>
<author-url>https://soundcloud.com/the-bugle</author-url>
</oembed>
Now unfurl use of htmlparser assumes that any content on the html block will show up as a new tag but that is not the case here, it will show up as text.
So what I have done is to naively check for the tagname while we read text and assume that if we have any text on an html tag it will be for something like this. In that scenario I have, again verynaively, escaped that < and > adn the CDATA and push that string into the content.html.
I have added a new test to cover this, including the example from soudlocud, and everything seems fine. There is certainly room for improvement, that sanitisation of the CDATA is not the best but it does the job for the type of content that we will usually get in that field.
Thanks for raising this. The purposed solution does worry me a bit. I have something that should (hopefully) be more robust and will raise separate PR for you to checkout.
While doing some tests with
unfurl
I stumble upon Soundcloud XML implementation which was only partially working.Looking at their XML it seems that they are escaping their html node with
CDATA
which is not unreasonable to be fair:Now unfurl use of htmlparser assumes that any content on the html block will show up as a new tag but that is not the case here, it will show up as text.
So what I have done is to naively check for the tagname while we read text and assume that if we have any text on an html tag it will be for something like this. In that scenario I have, again verynaively, escaped that
<
and>
adn theCDATA
and push that string into thecontent.html
.I have added a new test to cover this, including the example from soudlocud, and everything seems fine. There is certainly room for improvement, that sanitisation of the
CDATA
is not the best but it does the job for the type of content that we will usually get in that field.