diff --git a/resources/views/atom.blade.php b/resources/views/atom.blade.php
index 8cbcb30..a9be43f 100644
--- a/resources/views/atom.blade.php
+++ b/resources/views/atom.blade.php
@@ -7,7 +7,7 @@
@if($key === 'link')
<{{ $key }} href="{{ url($metaItem) }}" rel="self">{{ $key }}>
@elseif($key === 'title')
- <{{ $key }}>{{ $key }}>
+ <{{ $key }}>{!! \Spatie\Feed\Helpers\Cdata::out($metaItem) !!}{{ $key }}>
@elseif($key === 'description')
{{ $metaItem }}
@elseif($key === 'language')
@@ -23,18 +23,18 @@
@endforeach
@foreach($items as $item)
- title }}]]>
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->title) !!}
{{ url($item->id) }}
- authorName }}]]>
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->authorName) !!}
@if(!empty($item->authorEmail))
- authorEmail }}]]>
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->authorEmail) !!}
@endif
- summary !!}]]>
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->summary) !!}
@if($item->__isset('enclosure'))
diff --git a/resources/views/json.blade.php b/resources/views/json.blade.php
index 59ef3c7..32f6055 100644
--- a/resources/views/json.blade.php
+++ b/resources/views/json.blade.php
@@ -18,13 +18,13 @@
],
"items": [@foreach($items as $item){
"id": "{{ url($item->id) }}",
- "title": "{{ $item->title }}",
+ "title": {!! json_encode($item->title) !!},
"url": "{{ url($item->link) }}",
"content_html": {!! json_encode($item->summary) !!},
"summary": {!! json_encode($item->summary) !!},
"date_published": "{{ $item->timestamp() }}",
"date_modified": "{{ $item->timestamp() }}",
- "authors": [{ "name": "{{ $item->authorName }}" }],
+ "authors": [{ "name": {!! json_encode($item->authorName) !!} }],
@if($item->__isset('image'))
"image": "{{ url($item->image) }}",
@endif
diff --git a/resources/views/rss.blade.php b/resources/views/rss.blade.php
index 8ea6106..511779e 100644
--- a/resources/views/rss.blade.php
+++ b/resources/views/rss.blade.php
@@ -5,25 +5,25 @@
-
-
+ {!! \Spatie\Feed\Helpers\Cdata::out($meta['title'] ) !!}
+ {!! \Spatie\Feed\Helpers\Cdata::out(url($meta['link']) ) !!}
@if(!empty($meta['image']))
{{ $meta['image'] }}
-
-
+ {!! \Spatie\Feed\Helpers\Cdata::out($meta['title'] ) !!}
+ {!! \Spatie\Feed\Helpers\Cdata::out(url($meta['link']) ) !!}
@endif
-
+ {!! \Spatie\Feed\Helpers\Cdata::out($meta['description'] ) !!}
{{ $meta['language'] }}
{{ $meta['updated'] }}
@foreach($items as $item)
-
- title }}]]>
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->title) !!}
{{ url($item->link) }}
- summary !!}]]>
- authorName }}@if(!empty($item->authorEmail)) <{{ $item->authorEmail }}>@endif]]>
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->summary) !!}
+ {!! \Spatie\Feed\Helpers\Cdata::out($item->authorName.(empty($item->authorEmail)?'':' <'.$item->authorEmail.'>')) !!}
{{ url($item->id) }}
{{ $item->timestamp() }}
@foreach($item->category as $category)
diff --git a/src/Helpers/Cdata.php b/src/Helpers/Cdata.php
new file mode 100644
index 0000000..3c5f661
--- /dev/null
+++ b/src/Helpers/Cdata.php
@@ -0,0 +1,17 @@
+ '', // CDATA cannot be nested.
+ ']]>' => ']]>', // CDEnd needs to be escaped.
+ ];
+ return '';
+ }
+
+}
diff --git a/tests/DummyItem.php b/tests/DummyItem.php
index dfeae45..7f1c83a 100644
--- a/tests/DummyItem.php
+++ b/tests/DummyItem.php
@@ -16,7 +16,7 @@ public function toFeedItem(): FeedItem
{
return new FeedItem([
'id' => $this->id,
- 'title' => 'feedItemTitle',
+ 'title' => 'feed<>]]>Item"Title"',
'summary' => 'feedItemSummary',
'enclosure' => 'http://localhost/image1.jpg',
'enclosureLength' => 31300,
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.php b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.php
index c021639..087b8c6 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.php
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.php
@@ -9,7 +9,7 @@
en-US
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -25,7 +25,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -41,7 +41,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -57,7 +57,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -73,7 +73,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.txt b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.txt
index e877e22..55e0047 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.txt
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__1.txt
@@ -7,7 +7,7 @@
This is feed 1 from the unit tests
2015-12-31T22:59:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -23,7 +23,7 @@
2015-12-31T22:59:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/2
@@ -39,7 +39,7 @@
2015-12-31T22:58:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/3
@@ -55,7 +55,7 @@
2015-12-31T22:57:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/4
@@ -71,7 +71,7 @@
2015-12-31T22:56:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/5
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.php b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.php
index 580a4d0..6d65978 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.php
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.php
@@ -9,7 +9,7 @@
en-US
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -25,7 +25,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -41,7 +41,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -57,7 +57,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -73,7 +73,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.txt b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.txt
index d163e8d..acf4c51 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.txt
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__2.txt
@@ -7,7 +7,7 @@
This is feed 2 from the unit tests
2015-12-31T22:59:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -23,7 +23,7 @@
2015-12-31T22:59:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/2
@@ -39,7 +39,7 @@
2015-12-31T22:58:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/3
@@ -55,7 +55,7 @@
2015-12-31T22:57:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/4
@@ -71,7 +71,7 @@
2015-12-31T22:56:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/5
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.php b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.php
index 647dcb6..0f0691b 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.php
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.php
@@ -9,7 +9,7 @@
en-US
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -25,7 +25,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -41,7 +41,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -57,7 +57,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -73,7 +73,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
+ ]]>Item"Title"]]>
http://localhost/1
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.txt b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.txt
index 24f48ec..ce3a814 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.txt
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__3.txt
@@ -7,7 +7,7 @@
This is feed 3 from the unit tests
2015-12-31T22:59:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/1
@@ -23,7 +23,7 @@
2015-12-31T22:59:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/2
@@ -39,7 +39,7 @@
2015-12-31T22:58:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/3
@@ -55,7 +55,7 @@
2015-12-31T22:57:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/4
@@ -71,7 +71,7 @@
2015-12-31T22:56:00+00:00
-
+ ]]>Item"Title"]]>
http://localhost/5
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.php b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.php
index 9322d67..4374177 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.php
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.php
@@ -10,7 +10,7 @@
Fri, 01 Jan 2016 00:00:00 +0100
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem1
@@ -19,7 +19,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem1
@@ -28,7 +28,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem1
@@ -37,7 +37,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem1
@@ -46,7 +46,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem1
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.txt b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.txt
index 7d8e819..41be526 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.txt
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__4.txt
@@ -14,7 +14,7 @@
Thu, 31 Dec 2015 22:59:00 +0000
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem1
]]>
@@ -23,7 +23,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem2
]]>
@@ -32,7 +32,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem3
]]>
@@ -41,7 +41,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem4
]]>
@@ -50,7 +50,7 @@
feedItemCategory
-
-
+ ]]>Item"Title"]]>
https://localhost/news/testItem5
]]>
diff --git a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__5.txt b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__5.txt
index 184beb0..9a0a9ee 100644
--- a/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__5.txt
+++ b/tests/__snapshots__/FeedTest__all_feed_items_have_expected_data__5.txt
@@ -12,7 +12,7 @@
],
"items": [{
"id": "http://localhost/1",
- "title": "feedItemTitle",
+ "title": "feed<>]]>Item\"Title\"",
"url": "https://localhost/news/testItem1",
"content_html": "feedItemSummary",
"summary": "feedItemSummary",
@@ -30,7 +30,7 @@
},
{
"id": "http://localhost/2",
- "title": "feedItemTitle",
+ "title": "feed<>]]>Item\"Title\"",
"url": "https://localhost/news/testItem2",
"content_html": "feedItemSummary",
"summary": "feedItemSummary",
@@ -48,7 +48,7 @@
},
{
"id": "http://localhost/3",
- "title": "feedItemTitle",
+ "title": "feed<>]]>Item\"Title\"",
"url": "https://localhost/news/testItem3",
"content_html": "feedItemSummary",
"summary": "feedItemSummary",
@@ -66,7 +66,7 @@
},
{
"id": "http://localhost/4",
- "title": "feedItemTitle",
+ "title": "feed<>]]>Item\"Title\"",
"url": "https://localhost/news/testItem4",
"content_html": "feedItemSummary",
"summary": "feedItemSummary",
@@ -84,7 +84,7 @@
},
{
"id": "http://localhost/5",
- "title": "feedItemTitle",
+ "title": "feed<>]]>Item\"Title\"",
"url": "https://localhost/news/testItem5",
"content_html": "feedItemSummary",
"summary": "feedItemSummary",