Skip to content

Option to specify CDATA wrapper for content#28

Closed
tmshv wants to merge 2 commits into
dylang:masterfrom
tmshv:master
Closed

Option to specify CDATA wrapper for content#28
tmshv wants to merge 2 commits into
dylang:masterfrom
tmshv:master

Conversation

@tmshv

@tmshv tmshv commented Feb 9, 2014

Copy link
Copy Markdown

No description provided.

@tmshv tmshv mentioned this pull request Feb 9, 2014
@dylang

dylang commented Sep 26, 2014

Copy link
Copy Markdown
Owner

I like your change, and how you cleaned up the formatting. Can somebody else review this change and give a 👍 if it looks good?

@Mithgol

Mithgol commented Sep 27, 2014

Copy link
Copy Markdown
Contributor

This change seems fine, but some additional changes in README might become necessary.

Comment thread lib/rss.js

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will result in options.cdata = true when cdata is passed in as false, so CDATA wrapping always occurs.

Add this to the bottom of the tests to expose the bug:

    it('should wrap elements with CDATA', function(done) {
        var feed = new RSS({
            title: 'title',
            description: 'description',
            feed_url: 'http://example.com/rss.xml',
            site_url: 'http://example.com',
            cdata: true
        });

        var expectedResult = '<?xml version="1.0" encoding="UTF-8"?>\n'+
                             '<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">'+
                                 '<channel>'+
                                     '<title><![CDATA[title]]></title>'+
                                     '<description><![CDATA[description]]></description>'+
                                     '<link>http://example.com</link>'+
                                     '<generator>RSS for Node</generator>'+
                                     '<lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate>'+
                                     '<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>'+
                                 '</channel>'+
                             '</rss>';

        var result = feed.xml();

        expect(result).to.equal(expectedResult);
        done();
    });

    it('should wrap not elements with CDATA', function(done) {
        var feed = new RSS({
            title: 'title',
            description: 'description',
            feed_url: 'http://example.com/rss.xml',
            site_url: 'http://example.com',
            cdata: false
        });

        var expectedResult = '<?xml version="1.0" encoding="UTF-8"?>\n'+
                             '<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">'+
                                 '<channel>'+
                                     '<title>title</title>'+
                                     '<description>description</description>'+
                                     '<link>http://example.com</link>'+
                                     '<generator>RSS for Node</generator>'+
                                     '<lastBuildDate>' + new Date().toUTCString() +'</lastBuildDate>'+
                                     '<atom:link href="http://example.com/rss.xml" rel="self" type="application/rss+xml"/>'+
                                 '</channel>'+
                             '</rss>';

        var result = feed.xml();

        expect(result).to.equal(expectedResult);
        done();
    });

@dylang

dylang commented Feb 8, 2015

Copy link
Copy Markdown
Owner

Closing in favor of #38. Thanks for getting this started @tmshv!

@dylang dylang closed this Feb 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants