@@ -442,9 +442,9 @@ module Agents |
||
| 442 | 442 |
when Nokogiri::XML::NodeSet |
| 443 | 443 |
result = nodes.map { |node|
|
| 444 | 444 |
value = node.xpath(extraction_details['value'] || '.') |
| 445 |
- if extraction_details['strip_cdata'] |
|
| 445 |
+ if value.is_a?(Nokogiri::XML::NodeSet) |
|
| 446 | 446 |
child = value.first |
| 447 |
- if child.cdata? |
|
| 447 |
+ if child && child.cdata? |
|
| 448 | 448 |
value = child.text |
| 449 | 449 |
end |
| 450 | 450 |
end |
@@ -543,8 +543,8 @@ describe Agents::WebsiteAgent do |
||
| 543 | 543 |
'url' => 'http://example.com/cdata_rss.atom', |
| 544 | 544 |
'mode' => 'on_change', |
| 545 | 545 |
'extract' => {
|
| 546 |
- 'author' => { 'xpath' => '/feed/entry/author/name', 'value' => './/text()', 'strip_cdata' => true },
|
|
| 547 |
- 'title' => { 'xpath' => '/feed/entry/title', 'value' => './/text()', 'strip_cdata' => false },
|
|
| 546 |
+ 'author' => { 'xpath' => '/feed/entry/author/name', 'value' => './/text()'},
|
|
| 547 |
+ 'title' => { 'xpath' => '/feed/entry/title', 'value' => './/text()' },
|
|
| 548 | 548 |
'content' => { 'xpath' => '/feed/entry/content', 'value' => './/text()' },
|
| 549 | 549 |
} |
| 550 | 550 |
}, keep_events_for: 2.days) |
@@ -558,8 +558,8 @@ describe Agents::WebsiteAgent do |
||
| 558 | 558 |
}.to change { Event.count }.by(10)
|
| 559 | 559 |
event = Event.last |
| 560 | 560 |
expect(event.payload['author']).to eq('bill98')
|
| 561 |
- expect(event.payload['title']).to eq('<![CDATA[Help: Rainmeter Skins • Test if Today is Between 2 Dates]]>')
|
|
| 562 |
- expect(event.payload['content']).to start_with('<![CDATA[Can I ')
|
|
| 561 |
+ expect(event.payload['title']).to eq('Help: Rainmeter Skins • Test if Today is Between 2 Dates')
|
|
| 562 |
+ expect(event.payload['content']).to start_with('Can I ')
|
|
| 563 | 563 |
end |
| 564 | 564 |
|
| 565 | 565 |
end |