Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement correct coverage of the sanitizers

  • Loading branch information...
commit ddb140f4a4f5bac7ab54499b87a76f511a9fe6f6 1 parent ebe9ce9
@CloCkWeRX CloCkWeRX authored
View
6 XML/Feed/Parser.php
@@ -110,10 +110,12 @@ function __construct($feed, $strict = false, $suppressWarnings = false, $tidy =
function initialize($feed, $strict = false, $suppressWarnings = false, $tidy = false)
{
$factory = new XML_Feed_Parser_Factory();
- $this->feed = $factory->build($this->model, $feed, $strict, $suppressWarnings, $tidy);
+ $this->setFeed($factory->build($this->model, $feed, $strict, $suppressWarnings, $tidy));
}
-
+ public function setFeed($feed) {
+ $this->feed = $feed;
+ }
/**
* Proxy to allow feed element names to be used as method names
View
1  XML/Feed/Parser/Atom.php
@@ -149,6 +149,7 @@ function getEntryById($id)
if ($entries->length > 0) {
$xmlBase = $entries->item(0)->baseURI;
+ /** @todo Avoid instantiating classes we can't keep track of */
$entry = new $this->itemClass($entries->item(0), $this, $xmlBase);
if (in_array('evaluate', get_class_methods($this->xpath))) {
View
3  XML/Feed/Parser/AtomElement.php
@@ -90,7 +90,8 @@ class XML_Feed_Parser_AtomElement extends XML_Feed_Parser_Atom
*/
function __construct(DOMElement $element, $parent, $xmlBase = '')
{
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
+
+ $this->setSanitizer($parent->getSanitizer());
$this->model = $element;
$this->parent = $parent;
$this->xmlBase = $xmlBase;
View
3  XML/Feed/Parser/RSS09Element.php
@@ -56,8 +56,7 @@ function __construct(DOMElement $element, $parent, $xmlBase = '')
{
$this->model = $element;
$this->parent = $parent;
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
+ $this->setSanitizer($parent->getSanitizer());
}
}
-?>
View
2  XML/Feed/Parser/RSS11Element.php
@@ -82,7 +82,7 @@ function __construct(DOMElement $element, $parent, $xmlBase = '')
{
$this->model = $element;
$this->parent = $parent;
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
+ $this->setSanitizer($parent->getSanitizer());
}
/**
View
2  XML/Feed/Parser/RSS1Element.php
@@ -82,7 +82,7 @@ function __construct(DOMElement $element, $parent, $xmlBase = '')
{
$this->model = $element;
$this->parent = $parent;
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
+ $this->setSanitizer($parent->getSanitizer());
}
/**
View
2  XML/Feed/Parser/RSS2Element.php
@@ -77,7 +77,7 @@ function __construct(DOMElement $element, $parent, $xmlBase = '')
{
$this->model = $element;
$this->parent = $parent;
- $this->setSanitizer(new XML_Feed_Parser_Unsafe_Sanitizer());
+ $this->setSanitizer($parent->getSanitizer());
}
/**
View
1  XML/Feed/Parser/Sanitizer.php
@@ -6,6 +6,7 @@ public function sanitize($input);
class XML_Feed_Parser_Unsafe_Sanitizer implements XML_Feed_Parser_Sanitizer {
public function sanitize($input) {
+throw new Exception("Wrong sanitizer");
return $input;
}
}
View
3  XML/Feed/Parser/Type.php
@@ -113,6 +113,9 @@ function __call($call, $arguments = array())
public function setSanitizer(XML_Feed_Parser_Sanitizer $sanitizer) {
$this->sanitizer = $sanitizer;
}
+ public function getSanitizer() {
+ return $this->sanitizer;
+ }
/**
* Proxy to allow use of element names as attribute names
View
1  tests/XML_Feed_Parser_TestCase.php
@@ -19,6 +19,7 @@ static function getSampleDir() {
function setup() {
$this->fp_test_dir = XML_Feed_Parser_TestCase::getSampleDir() .
DIRECTORY_SEPARATOR . 'feedparsertests';
+
if (! is_dir($this->fp_test_dir)) {
$this->markTestSkipped('Feed parser tests (http://code.google.com/p/feedparser/downloads/list) must be unpacked into the folder ' .
$this->fp_test_dir);
View
1,257 tests/convertedtests/sanitize.php
840 additions, 417 deletions not shown
Please sign in to comment.
Something went wrong with that request. Please try again.