Raghuveersingh / google-ajax-apis

Automatically exported from code.google.com/p/google-ajax-apis
0 stars 0 forks source link

feed api issue (contentSnippet not filtering out HTML comments) #608

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  here is the code:

/*
*  How to load a feed via the Feeds API. (START)
*/

google.load("feeds", "1");

// Our callback function, for when a feed is loaded.
function feedLoaded(result) {
  if (!result.error) {
    // Grab the container we will put the results into
    var container = document.getElementById("content");
    container.innerHTML = '';

    // Loop through the feeds, putting the titles onto the page.
    // Check out the result object for a list of properties returned in each entry.
    // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON
    for (var i = 0; i < result.feed.entries.length; i++) {
      var entry = result.feed.entries[i];
      var div = document.createElement("div");
      div.appendChild(document.createTextNode(entry.contentSnippet));
      container.appendChild(div);
    }
  }
}

function OnLoad() {
  // Create a feed instance that will grab Digg's feed.
  var feed = new google.feeds.Feed("http://gizmodo.net/index.xml");

  // Calling load sends the request off.  It requires a callback function.
  feed.load(feedLoaded);
}

google.setOnLoadCallback(OnLoad);​
/*
*  How to load a feed via the Feeds API. (END)
*/

What is the expected output? What do you see instead?

expecting contentSnippet to have all HTML (including HTML comments) filtered 
out.
however, with the Gizmodo RSS feed, the contentSnippets are all HTML comments.

What version of the product are you using? On what operating system?

using chrome browser on OS X snow leopard to a linux apache web server

Please provide any additional information below.

in the Google Feed API docs:

    http://code.google.com/apis/feed/v1/jsondevguide.html#resultJson

it says:

    contentSnippet
        A snippet (< 120 characters) version of the content attribute. 
        The snippet does not contain any HTML tags.

however, html comments are not being filtered, so contentSnippet values can 
sometimes
be nothing but html comments!:

from an RSS feed like:

<xml>
    ...
    <item>
        <description>
            &lt;!-- html comment stuff here --&gt;
        </description>
        ...
    </item>
</xml>

Original issue reported on code.google.com by mtn.ri...@gmail.com on 11 Aug 2011 at 9:02