Skip to content

Commit dfa5f57

Browse files
authored
Merge branch 'dev/2.1.0' into magikid-patch-1
2 parents 60eaead + a116fe1 commit dfa5f57

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+150
-196
lines changed

CHANGELOG.md

Lines changed: 11 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,17 @@
11
### Development
22

3-
## 1.7.0
3+
All notable changes to this project will be documented in this file.
44

5-
- Added .scrutinizer.yml to repo
6-
- Reformated code to PSR-1/2
7-
- Improved the test coverage and some small code changes
8-
- Added removeAttribute and removeAllAttributes tag methods fixes #57
9-
- Added replaceNode method implements #52
10-
- Added a delete method. fixes #43
11-
- Added semicolon after &#10 for linebreak preservation. fixes #62
12-
- Removed code that removed <code> tag fixes #60
13-
- Added new test related to #63
14-
- Refactored the nodes into inner and leaf nodes
15-
- Fixed Strings example in README
16-
- Close this header so the markdown will render properly
17-
- Added preserve line break option. Defaults to false.
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
187

8+
## [Unreleased]
199

20-
## 1.6.9
10+
### Added
11+
- New `removeSmartyScripts` configuration setting. Defaults to true.
12+
- Added `declare(strict_types=1)` to all source files.
2113

22-
- Added Changelog
23-
- Fixed issue with spaces befor closing tag Fixes #45
24-
- Fixed some code quality issues found by scrutinizer
25-
- Added Scrutinizer to README
26-
- Reformated code to comply with PSR-1/2
27-
- Added preserve line break option. Defaults to false. fixes #40
28-
- Updated the tests
29-
- Added options: cleanupInput, removeScripts and removeStyles
30-
31-
## 1.6.8
32-
33-
- Added comments and reformated some code
34-
- Added support for non-escaped quotes in attribute value fixes #37
35-
- Cleaned up the comments and php docs
36-
- Removed version in composer json
37-
- Updated composer version
38-
- Refactoring out isChild method.
39-
- Updated in code documentation
40-
- Updated composer
41-
42-
$$ 1.6.7
43-
44-
- Added tests for the new array access
45-
- Added feature to allow array usage of html node. fixes #26
46-
- Update HtmlNode.php
47-
- Added test to cover issue #28
48-
- FIX: File name is longer than the maximum allowed path
49-
50-
## 1.6.6
51-
52-
- Replaced preg_replace with mb_ereg_replace
53-
- Added child selector fixes #24
54-
- Updated the dev version of phpunit
55-
56-
## 1.6.5
57-
58-
- Fixed bug when no attribute tags are last tag (with out space). fixes #16
59-
- Fixed some documentation inconsistencies fixes #15
60-
- Made loadStr a public methor Fixes #18
61-
- Update a problem with the README fixes #11
62-
- Added setAttribute to the node fixes #7
63-
- Check if open_basedir is enabled: Dont use CURLOPT_FOLLOWLOCATION
64-
65-
## 1.6.4
66-
67-
- Added tests and updated README
68-
- Updated the tests and moved some files
69-
- Added the option to enforce the encoding
70-
- Fixed a problem with handeling the unknown child exception
71-
- Updated some tests
72-
- Added coverall badge and package
73-
74-
## 1.6.3
75-
76-
- Added initial support for 'strict' parsing option
77-
- Added an optional paramter to enable recursive text
78-
- Added appropriat Options tests
79-
- Changed all exception to specific objects
80-
- Added a whitespaceTextNode option and test
81-
- Added support for an options array
82-
83-
## 1.6.2
84-
85-
- Standardised indentation for easyer reading on github
86-
- Update AbstractNode.php
87-
- Added a test for hhvm in my travis.yml
88-
- Added a LICENSE.md file for MIT
89-
- Added build status to README
90-
- Added travis.yml
91-
- Changed the file name of the abstract node
92-
- fixed code in collection class where instance of arrayIterator is to be rturned
93-
- Updated documentation
94-
- Added a curl interface and a simple curl class.
95-
- Removed the Guzzle dependancy
96-
- Abstracted the Node class as it should have been done in the first place
97-
- Added integrity checks for the cached html
98-
- Added some basic caching of the dom html
99-
- Added a toArray() method to the collection and a test
100-
101-
## 1.6.1
102-
103-
- Moved back to using guzzle so expections are thrown when their was an error with loading a url
104-
- Added tests for the Static Facade Fixed a few issues brought to light from the new tests
105-
- Added a static facade
106-
- Changed encoding to be a local attribute instead of a static attribute
107-
- Solved issue #2 When you attempt to load an html page from a URL using loadFromUrl the encoding is incorrect.
108-
- Added easyer loading of files and urls. Still have a problem with encoding while loading from url.
109-
- Added guzzle and loadFromUrl option
110-
- Fixed an issue with no value attributes
111-
- Added magic and each methods to the collection. Plus some tests
112-
- Added a collection object
113-
- Added charset encoding
114-
- fixed a bug with closing tags If a closing tag did not have an opening tag it would cause the scan to end instead of ignoring the closing tag.
14+
### Changed
15+
- Started using a changelog.
16+
- Fixed bug that caused an infinite loop when no content found in tags.
17+
- Moved the Mock object to the tests directory, where it belongs.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ Preserves Line Breaks if set to `true`. If set to `false` line breaks are cleane
172172

173173
Set this to `false` if you want to preserve whitespace inside of text nodes. It is set to `true` by default.
174174

175+
176+
**removeSmartyScripts**
177+
178+
Set this to `false` if you want to preserve smarty sccript found in the html content. It is set to `true` by default.
179+
175180
Static Facade
176181
-------------
177182

src/PHPHtmlParser/Content.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser;
33

44
/**

src/PHPHtmlParser/Curl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser;
33

44
use PHPHtmlParser\Exceptions\CurlException;

src/PHPHtmlParser/CurlInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser;
33

44
/**

src/PHPHtmlParser/Dom.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser;
33

44
use PHPHtmlParser\Dom\AbstractNode;
@@ -502,24 +502,26 @@ protected function clean(string $str): string
502502
$str = mb_eregi_replace("<!\[CDATA\[(.*?)\]\]>", '', $str);
503503

504504
// strip out <script> tags
505-
if ($this->options->get('removeScripts') == true) {
505+
if ($this->options->get('removeScripts')) {
506506
$str = mb_eregi_replace("<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>", '', $str);
507507
$str = mb_eregi_replace("<\s*script\s*>(.*?)<\s*/\s*script\s*>", '', $str);
508508
}
509509

510510
// strip out <style> tags
511-
if ($this->options->get('removeStyles') == true) {
511+
if ($this->options->get('removeStyles')) {
512512
$str = mb_eregi_replace("<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>", '', $str);
513513
$str = mb_eregi_replace("<\s*style\s*>(.*?)<\s*/\s*style\s*>", '', $str);
514514
}
515515

516516
// strip out server side scripts
517-
if ($this->options->get('serverSideScriptis') == true){
517+
if ($this->options->get('serverSideScripts')) {
518518
$str = mb_eregi_replace("(<\?)(.*?)(\?>)", '', $str);
519519
}
520520

521521
// strip smarty scripts
522-
$str = mb_eregi_replace("(\{\w)(.*?)(\})", '', $str);
522+
if ($this->options->get('removeSmartyScripts')) {
523+
$str = mb_eregi_replace("(\{\w)(.*?)(\})", '', $str);
524+
}
523525

524526
return $str;
525527
}
@@ -626,6 +628,11 @@ protected function parseTag(): array
626628
}
627629

628630
$tag = strtolower($this->content->copyByToken('slash', true));
631+
if (trim($tag) == '')
632+
{
633+
// no tag found, invalide < found
634+
return $return;
635+
}
629636
$node = new HtmlNode($tag);
630637

631638
// attributes

src/PHPHtmlParser/Dom/AbstractNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser\Dom;
33

44
use PHPHtmlParser\Exceptions\CircularException;

src/PHPHtmlParser/Dom/ArrayNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser\Dom;
33

44
use Countable;

src/PHPHtmlParser/Dom/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser\Dom;
33

44
use ArrayAccess;

src/PHPHtmlParser/Dom/HtmlNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php
1+
<?php declare(strict_types=1);
22
namespace PHPHtmlParser\Dom;
33

44
use PHPHtmlParser\Exceptions\UnknownChildTypeException;

0 commit comments

Comments
 (0)