@@ -3,12 +3,12 @@ discard block |
||
| 3 | 3 | class SS_HTML5Value extends SS_HTMLValue { |
| 4 | 4 | |
| 5 | 5 | public function setContent($content) { |
| 6 | - require_once(HTML5LIB_PATH.'/HTML5/Parser.php'); |
|
| 6 | + require_once(HTML5LIB_PATH . '/HTML5/Parser.php'); |
|
| 7 | 7 | |
| 8 | 8 | // Convert any errors to exceptions |
| 9 | 9 | set_error_handler( |
| 10 | - function($no, $str){ |
|
| 11 | - throw new Exception("HTML Parse Error: ".$str); |
|
| 10 | + function($no, $str) { |
|
| 11 | + throw new Exception("HTML Parse Error: " . $str); |
|
| 12 | 12 | }, |
| 13 | 13 | error_reporting() |
| 14 | 14 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | // Use HTML5lib to parse the HTML fragment |
| 17 | 17 | try { |
| 18 | 18 | $document = HTML5_Parser::parse( |
| 19 | - '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>'. |
|
| 19 | + '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>' . |
|
| 20 | 20 | "<body>$content</body></html>" |
| 21 | 21 | ); |
| 22 | 22 | } |
@@ -19,8 +19,7 @@ discard block |
||
| 19 | 19 | '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head>'. |
| 20 | 20 | "<body>$content</body></html>" |
| 21 | 21 | ); |
| 22 | - } |
|
| 23 | - catch (Exception $e) { |
|
| 22 | + } catch (Exception $e) { |
|
| 24 | 23 | $document = false; |
| 25 | 24 | } |
| 26 | 25 | |
@@ -28,8 +27,11 @@ discard block |
||
| 28 | 27 | restore_error_handler(); |
| 29 | 28 | |
| 30 | 29 | // If we couldn't parse the HTML, set the error state |
| 31 | - if ($document) $this->setDocument($document); |
|
| 32 | - else $this->setInvalid(); |
|
| 30 | + if ($document) { |
|
| 31 | + $this->setDocument($document); |
|
| 32 | + } else { |
|
| 33 | + $this->setInvalid(); |
|
| 34 | + } |
|
| 33 | 35 | } |
| 34 | 36 | |
| 35 | 37 | } |
| 36 | 38 | \ No newline at end of file |
@@ -7,13 +7,13 @@ discard block |
||
| 7 | 7 | public function testInvalidHTMLParsing() { |
| 8 | 8 | $value = new SS_HTML5Value(); |
| 9 | 9 | |
| 10 | - $invalid = array ( |
|
| 10 | + $invalid = array( |
|
| 11 | 11 | '<p>Enclosed Value</p></p>' => '<p>Enclosed Value</p><p></p>', |
| 12 | 12 | '<meta content="text/html"></meta>' => '<meta content="text/html">', |
| 13 | 13 | '<p><div class="example"></div></p>' => '<p></p><div class="example"></div><p></p>' |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - foreach($invalid as $input => $expected) { |
|
| 16 | + foreach ($invalid as $input => $expected) { |
|
| 17 | 17 | $value->setContent($input); |
| 18 | 18 | $this->assertEquals($expected, $value->getContent(), 'Invalid HTML can be parsed'); |
| 19 | 19 | } |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | '<html><div><a href="test-link"></a></a></html_>' |
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - foreach($invalid as $input) { |
|
| 44 | + foreach ($invalid as $input) { |
|
| 45 | 45 | $value->setContent($input); |
| 46 | 46 | |
| 47 | 47 | $this->assertEquals( |