Skip to content

Commit

Permalink
update to php7.3
Browse files Browse the repository at this point in the history
Reference 
sunra#83
  • Loading branch information
fdjkgh580 authored Apr 23, 2020
1 parent fa1052a commit a744911
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Src/Sunra/PhpSimple/simplehtmldom_1_5/simple_html_dom.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
// -----------------------------------------------------------------------------
// get html dom from file
// $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
function file_get_html($url, $use_include_path = false, $context=null, $offset=0, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
{
// We DO force the tags to be terminated.
$dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
Expand Down Expand Up @@ -693,7 +693,7 @@ protected function parse_selector($selector_string) {
// This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
// farther study is required to determine of this should be documented or removed.
// $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
$pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
$pattern = "/([\w\-:\*]*)(?:\#([\w\-]+)|\.([\w\-]+))?(?:\[@?(!?[\w\-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);}

Expand Down Expand Up @@ -821,11 +821,11 @@ function convert_text($text)
}

/**
* Returns true if $string is valid UTF-8 and false otherwise.
*
* @param mixed $str String to be tested
* @return boolean
*/
* Returns true if $string is valid UTF-8 and false otherwise.
*
* @param mixed $str String to be tested
* @return boolean
*/
static function is_utf8($str)
{
$c=0; $b=0;
Expand Down Expand Up @@ -899,9 +899,9 @@ function get_display_size()
{
// Thanks to user gnarf from stackoverflow for this regular expression.
$attributes = array();
preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
preg_match_all("/([\w\-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$attributes[$match[1]] = $match[2];
$attributes[$match[1]] = $match[2];
}

// If there is a width in the style attributes:
Expand Down Expand Up @@ -947,13 +947,13 @@ function get_display_size()
// If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.

$result = array('height' => $height,
'width' => $width);
'width' => $width);
return $result;
}

// camel naming conventions
function getAllAttributes() {return array_map('html_entity_decode', $this->attr);}
function getAttribute($name) {return html_entity_decode($this->__get($name));}
function getAllAttributes() {return $this->attr;}
function getAttribute($name) {return $this->__get($name);}
function setAttribute($name, $value) {$this->__set($name, $value);}
function hasAttribute($name) {return $this->__isset($name);}
function removeAttribute($name) {$this->__set($name, null);}
Expand Down Expand Up @@ -1023,7 +1023,7 @@ class simple_html_dom
'p'=>array('p'=>1),
'nobr'=>array('nobr'=>1),
'b'=>array('b'=>1),
'option'=>array('option'=>1),
'option'=>array('option'=>1),
);

function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
Expand Down Expand Up @@ -1245,7 +1245,7 @@ protected function parse_charset()
if (empty($charset))
{
// Have php try to detect the encoding from the text given to us.
$charset = (function_exists('mb_detect_encoding')) ? mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) ) : false;
$charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) );
if (is_object($debugObject)) {$debugObject->debugLog(2, 'mb_detect found: ' . $charset);}

// and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
Expand Down Expand Up @@ -1375,7 +1375,7 @@ protected function read_tag()
return true;
}

if (!preg_match("/^[\w-:]+$/", $tag)) {
if (!preg_match("/^[\w\-:]+$/", $tag)) {
$node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
if ($this->char==='<') {
$this->link_nodes($node, false);
Expand Down

0 comments on commit a744911

Please sign in to comment.