File tree Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Expand file tree Collapse file tree 4 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ public function appendTo(FeedInterface $feed)
147
147
*/
148
148
public function asXML ()
149
149
{
150
- $ xml = new SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8" ?><channel></channel> ' );
150
+ $ xml = new SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8" ?><channel></channel> ' , LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL );
151
151
$ xml ->addChild ('title ' , $ this ->title );
152
152
$ xml ->addChild ('link ' , $ this ->url );
153
153
$ xml ->addChild ('description ' , $ this ->description );
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ public function addChannel(ChannelInterface $channel)
28
28
*/
29
29
public function render ()
30
30
{
31
- $ xml = new SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" /> ' );
31
+ $ xml = new SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" /> ' , LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL );
32
32
33
33
foreach ( $ this ->channels as $ channel )
34
34
{
Original file line number Diff line number Diff line change @@ -107,7 +107,7 @@ public function appendTo(ChannelInterface $channel)
107
107
*/
108
108
public function asXML ()
109
109
{
110
- $ xml = new SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8" ?><item></item> ' );
110
+ $ xml = new SimpleXMLElement ('<?xml version="1.0" encoding="UTF-8" ?><item></item> ' , LIBXML_NOERROR | LIBXML_ERR_NONE | LIBXML_ERR_FATAL );
111
111
$ xml ->addChild ('title ' , $ this ->title );
112
112
$ xml ->addChild ('link ' , $ this ->url );
113
113
$ xml ->addChild ('description ' , $ this ->description );
Original file line number Diff line number Diff line change @@ -165,6 +165,20 @@ public function test_with_amp()
165
165
->description ('desc&desc ' );
166
166
$ expect = '<?xml version="1.0" encoding="UTF-8"?>
167
167
<item><title>test&test</title><link>url&url</link><description>desc&desc</description></item>
168
+ ' ;
169
+
170
+ $ this ->assertSame ($ expect , $ item ->asXML ()->asXML ());
171
+ }
172
+
173
+ public function test_fail_safe_against_invalid_string ()
174
+ {
175
+ $ item = new Item ();
176
+ $ item
177
+ ->title ("test \0test " )
178
+ ->url ("url \0test " )
179
+ ->description ("desc \0desc " );
180
+ $ expect = '<?xml version="1.0" encoding="UTF-8"?>
181
+ <item><title>test</title><link>url</link><description>desc</description></item>
168
182
' ;
169
183
170
184
$ this ->assertSame ($ expect , $ item ->asXML ()->asXML ());
You can’t perform that action at this time.
0 commit comments