3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Zend Framework (http://framework.zend.com/) * * @link http://github.com/zendframework/zf2 for the canonical source repository * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ /** * Context specific methods for use in secure output escaping */ class Escaper { /** * Entity Map mapping Unicode codepoints to any available named HTML entities. * * While HTML supports far more named entities, the lowest common denominator * has become HTML5's XML Serialisation which is restricted to the those named * entities that XML supports. Using HTML entities would result in this error: * XML Parsing Error: undefined entity * * @var array */ protected static $htmlNamedEntityMap = array( 34 => 'quot', // quotation mark 38 => 'amp', // ampersand 60 => 'lt', // less-than sign 62 => 'gt', // greater-than sign ); /** * Current encoding for escaping. If not UTF-8, we convert strings from this encoding * pre-escaping and back to this encoding post-escaping. * * @var string */ protected $encoding = 'utf-8'; /** * Holds the value of the special flags passed as second parameter to * htmlspecialchars(). We modify these for PHP 5.4 to take advantage * of the new ENT_SUBSTITUTE flag for correctly dealing with invalid * UTF-8 sequences. * * @var string */ protected $htmlSpecialCharsFlags = ENT_QUOTES; /** * Static Matcher which escapes characters for HTML Attribute contexts * * @var callable */ protected $htmlAttrMatcher; /** * Static Matcher which escapes characters for Javascript contexts * * @var callable */ protected $jsMatcher; /** * Static Matcher which escapes characters for CSS Attribute contexts * * @var callable */ protected $cssMatcher; /** * List of all encoding supported by this class * * @var array */ protected $supportedEncodings = array( 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', 'ibm866', '866', 'cp1251', 'windows-1251', 'win-1251', '1251', 'cp1252', 'windows-1252', '1252', 'koi8-r', 'koi8-ru', 'koi8r', 'big5', '950', 'gb2312', '936', 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', 'cp932', '932', 'euc-jp', 'eucjp', 'eucjp-win', 'macroman' ); /** * Constructor: Single parameter allows setting of global encoding for use by * the current object. If PHP 5.4 is detected, additional ENT_SUBSTITUTE flag * is set for htmlspecialchars() calls. * * @param string $encoding * @throws Exception */ public function __construct($encoding = null) { if ($encoding !== null) { $encoding = (string) $encoding; if ($encoding === '') { throw new Exception( get_class($this) . ' constructor parameter does not allow a blank value' ); } $encoding = strtolower($encoding); if (!in_array($encoding, $this->supportedEncodings)) { throw new Exception( 'Value of \'' . $encoding . '\' passed to ' . get_class($this) . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' ); } $this->encoding = $encoding; } if (defined('ENT_SUBSTITUTE')) { $this->htmlSpecialCharsFlags|= ENT_SUBSTITUTE; } // set matcher callbacks $this->htmlAttrMatcher = array($this, 'htmlAttrMatcher'); $this->jsMatcher = array($this, 'jsMatcher'); $this->cssMatcher = array($this, 'cssMatcher'); } /** * Return the encoding that all output/input is expected to be encoded in. * * @return string */ public function getEncoding() { return $this->encoding; } /** * Escape a string for the HTML Body context where there are very few characters * of special meaning. Internally this will use htmlspecialchars(). * * @param string $string * @return string */ public function escapeHtml($string) { return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); } /** * Escape a string for the HTML Attribute context. We use an extended set of characters * to escape that are not covered by htmlspecialchars() to cover cases where an attribute * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). * * @param string $string * @return string */ public function escapeHtmlAttr($string) { $string = $this->toUtf8($string); if ($string === '' || ctype_digit($string)) { return $string; } $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); return $this->fromUtf8($result); } /** * Escape a string for the Javascript context. This does not use json_encode(). An extended * set of characters are escaped beyond ECMAScript's rules for Javascript literal string * escaping in order to prevent misinterpretation of Javascript as HTML leading to the * injection of special characters and entities. The escaping used should be tolerant * of cases where HTML escaping was not applied on top of Javascript escaping correctly. * Backslash escaping is not used as it still leaves the escaped character as-is and so * is not useful in a HTML context. * * @param string $string * @return string */ public function escapeJs($string) { $string = $this->toUtf8($string); if ($string === '' || ctype_digit($string)) { return $string; } $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); return $this->fromUtf8($result); } /** * Escape a string for the URI or Parameter contexts. This should not be used to escape * an entire URI - only a subcomponent being inserted. The function is a simple proxy * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. * * @param string $string * @return string */ public function escapeUrl($string) { return rawurlencode($string); } /** * Escape a string for the CSS context. CSS escaping can be applied to any string being * inserted into CSS and escapes everything except alphanumerics. * * @param string $string * @return string */ public function escapeCss($string) { $string = $this->toUtf8($string); if ($string === '' || ctype_digit($string)) { return $string; } $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); return $this->fromUtf8($result); } /** * Callback function for preg_replace_callback that applies HTML Attribute * escaping to all matches. * * @param array $matches * @return string */ protected function htmlAttrMatcher($matches) { $chr = $matches[0]; $ord = ord($chr); /** * The following replaces characters undefined in HTML with the * hex entity for the Unicode replacement character. */ if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f) ) { return '&#xFFFD;'; } /** * Check if the current character to escape has a name entity we should * replace it with while grabbing the integer value of the character. */ if (strlen($chr) > 1) { $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); } $hex = bin2hex($chr); $ord = hexdec($hex); if (isset(static::$htmlNamedEntityMap[$ord])) { return '&' . static::$htmlNamedEntityMap[$ord] . ';'; } /** * Per OWASP recommendations, we'll use upper hex entities * for any other characters where a named entity does not exist. */ if ($ord > 255) { return sprintf('&#x%04X;', $ord); } return sprintf('&#x%02X;', $ord); } /** * Callback function for preg_replace_callback that applies Javascript * escaping to all matches. * * @param array $matches * @return string */ protected function jsMatcher($matches) { $chr = $matches[0]; if (strlen($chr) == 1) { return sprintf('\\x%02X', ord($chr)); } $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); return sprintf('\\u%04s', strtoupper(bin2hex($chr))); } /** * Callback function for preg_replace_callback that applies CSS * escaping to all matches. * * @param array $matches * @return string */ protected function cssMatcher($matches) { $chr = $matches[0]; if (strlen($chr) == 1) { $ord = ord($chr); } else { $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); $ord = hexdec(bin2hex($chr)); } return sprintf('\\%X ', $ord); } /** * Converts a string to UTF-8 from the base encoding. The base encoding is set via this * class' constructor. * * @param string $string * @throws Exception * @return string */ protected function toUtf8($string) { if ($this->getEncoding() === 'utf-8') { $result = $string; } else { $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); } if (!$this->isUtf8($result)) { throw new Exception( sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) ); } return $result; } /** * Converts a string from UTF-8 to the base encoding. The base encoding is set via this * class' constructor. * @param string $string * @return string */ protected function fromUtf8($string) { if ($this->getEncoding() === 'utf-8') { return $string; } return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8'); } /** * Checks if a given string appears to be valid UTF-8 or not. * * @param string $string * @return bool */ protected function isUtf8($string) { return ($string === '' || preg_match('/^./su', $string)); } /** * Encoding conversion helper which wraps iconv and mbstring where they exist or throws * and exception where neither is available. * * @param string $string * @param string $to * @param array|string $from * @throws Exception * @return string */ protected function convertEncoding($string, $to, $from) { if (function_exists('iconv')) { $result = iconv($from, $to, $string); } elseif (function_exists('mb_convert_encoding')) { $result = mb_convert_encoding($string, $to, $from); } else { throw new Exception( get_class($this) . ' requires either the iconv or mbstring extension to be installed' . ' when escaping for non UTF-8 strings.' ); } if ($result === false) { return ''; // return non-fatal blank string on encoding errors from users } return $result; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RUq42
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  384     0  E > > RETURN                                                   1

Class Escaper:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 37
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 14
Branch analysis from position: 7
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 35
Branch analysis from position: 25
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 40
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
Branch analysis from position: 37
filename:       /in/RUq42
function name:  __construct
number of ops:  56
compiled vars:  !0 = $encoding
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   96     0  E >   RECV_INIT                                        !0      null
   98     1        TYPE_CHECK                                  1020          !0
          2      > JMPZ                                                     ~1, ->37
   99     3    >   CAST                                          6  ~2      !0
          4        ASSIGN                                                   !0, ~2
  100     5        IS_IDENTICAL                                             !0, ''
          6      > JMPZ                                                     ~4, ->14
  101     7    >   NEW                                              $5      'Exception'
  102     8        FETCH_THIS                                       ~6      
          9        GET_CLASS                                        ~7      ~6
         10        CONCAT                                           ~8      ~7, '+constructor+parameter+does+not+allow+a+blank+value'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $5
  106    14    >   INIT_FCALL                                               'strtolower'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $10     
         17        ASSIGN                                                   !0, $10
  107    18        INIT_FCALL                                               'in_array'
         19        SEND_VAR                                                 !0
         20        FETCH_OBJ_R                                      ~12     'supportedEncodings'
         21        SEND_VAL                                                 ~12
         22        DO_ICALL                                         $13     
         23        BOOL_NOT                                         ~14     $13
         24      > JMPZ                                                     ~14, ->35
  108    25    >   NEW                                              $15     'Exception'
  109    26        CONCAT                                           ~16     'Value+of+%27', !0
         27        CONCAT                                           ~17     ~16, '%27+passed+to+'
         28        FETCH_THIS                                       ~18     
         29        GET_CLASS                                        ~19     ~18
         30        CONCAT                                           ~20     ~17, ~19
  110    31        CONCAT                                           ~21     ~20, '+constructor+parameter+is+invalid.+Provide+an+encoding+supported+by+htmlspecialchars%28%29'
         32        SEND_VAL_EX                                              ~21
         33        DO_FCALL                                      0          
         34      > THROW                                         0          $15
  114    35    >   ASSIGN_OBJ                                               'encoding'
         36        OP_DATA                                                  !0
  117    37    > > JMPZ                                                     <true>, ->40
  118    38    >   ASSIGN_OBJ_OP                                 9          'htmlSpecialCharsFlags'
         39        OP_DATA                                                  8
  122    40    >   FETCH_THIS                                       ~26     
         41        INIT_ARRAY                                       ~27     ~26
         42        ADD_ARRAY_ELEMENT                                ~27     'htmlAttrMatcher'
         43        ASSIGN_OBJ                                               'htmlAttrMatcher'
         44        OP_DATA                                                  ~27
  123    45        FETCH_THIS                                       ~29     
         46        INIT_ARRAY                                       ~30     ~29
         47        ADD_ARRAY_ELEMENT                                ~30     'jsMatcher'
         48        ASSIGN_OBJ                                               'jsMatcher'
         49        OP_DATA                                                  ~30
  124    50        FETCH_THIS                                       ~32     
         51        INIT_ARRAY                                       ~33     ~32
         52        ADD_ARRAY_ELEMENT                                ~33     'cssMatcher'
         53        ASSIGN_OBJ                                               'cssMatcher'
         54        OP_DATA                                                  ~33
  125    55      > RETURN                                                   null

End of function __construct

Function getencoding:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RUq42
function name:  getEncoding
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  134     0  E >   FETCH_OBJ_R                                      ~0      'encoding'
          1      > RETURN                                                   ~0
  135     2*     > RETURN                                                   null

End of function getencoding

Function escapehtml:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RUq42
function name:  escapeHtml
number of ops:  10
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  144     0  E >   RECV                                             !0      
  146     1        INIT_FCALL                                               'htmlspecialchars'
          2        SEND_VAR                                                 !0
          3        FETCH_OBJ_R                                      ~1      'htmlSpecialCharsFlags'
          4        SEND_VAL                                                 ~1
          5        FETCH_OBJ_R                                      ~2      'encoding'
          6        SEND_VAL                                                 ~2
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
  147     9*     > RETURN                                                   null

End of function escapehtml

Function escapehtmlattr:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/RUq42
function name:  escapeHtmlAttr
number of ops:  25
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  157     0  E >   RECV                                             !0      
  159     1        INIT_METHOD_CALL                                         'toUtf8'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
  160     5        IS_IDENTICAL                                     ~4      !0, ''
          6      > JMPNZ_EX                                         ~4      ~4, ->11
          7    >   INIT_FCALL                                               'ctype_digit'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        BOOL                                             ~4      $5
         11    > > JMPZ                                                     ~4, ->13
  161    12    > > RETURN                                                   !0
  164    13    >   INIT_FCALL                                               'preg_replace_callback'
         14        SEND_VAL                                                 '%2F%5B%5Ea-z0-9%2C%5C.%5C-_%5D%2FiSu'
         15        FETCH_OBJ_R                                      ~6      'htmlAttrMatcher'
         16        SEND_VAL                                                 ~6
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !1, $7
  165    20        INIT_METHOD_CALL                                         'fromUtf8'
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0  $9      
         23      > RETURN                                                   $9
  166    24*     > RETURN                                                   null

End of function escapehtmlattr

Function escapejs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/RUq42
function name:  escapeJs
number of ops:  25
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  180     0  E >   RECV                                             !0      
  182     1        INIT_METHOD_CALL                                         'toUtf8'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
  183     5        IS_IDENTICAL                                     ~4      !0, ''
          6      > JMPNZ_EX                                         ~4      ~4, ->11
          7    >   INIT_FCALL                                               'ctype_digit'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        BOOL                                             ~4      $5
         11    > > JMPZ                                                     ~4, ->13
  184    12    > > RETURN                                                   !0
  187    13    >   INIT_FCALL                                               'preg_replace_callback'
         14        SEND_VAL                                                 '%2F%5B%5Ea-z0-9%2C%5C._%5D%2FiSu'
         15        FETCH_OBJ_R                                      ~6      'jsMatcher'
         16        SEND_VAL                                                 ~6
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !1, $7
  188    20        INIT_METHOD_CALL                                         'fromUtf8'
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0  $9      
         23      > RETURN                                                   $9
  189    24*     > RETURN                                                   null

End of function escapejs

Function escapeurl:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RUq42
function name:  escapeUrl
number of ops:  6
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  199     0  E >   RECV                                             !0      
  201     1        INIT_FCALL                                               'rawurlencode'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
  202     5*     > RETURN                                                   null

End of function escapeurl

Function escapecss:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/RUq42
function name:  escapeCss
number of ops:  25
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  211     0  E >   RECV                                             !0      
  213     1        INIT_METHOD_CALL                                         'toUtf8'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $2      
          4        ASSIGN                                                   !0, $2
  214     5        IS_IDENTICAL                                     ~4      !0, ''
          6      > JMPNZ_EX                                         ~4      ~4, ->11
          7    >   INIT_FCALL                                               'ctype_digit'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $5      
         10        BOOL                                             ~4      $5
         11    > > JMPZ                                                     ~4, ->13
  215    12    > > RETURN                                                   !0
  218    13    >   INIT_FCALL                                               'preg_replace_callback'
         14        SEND_VAL                                                 '%2F%5B%5Ea-z0-9%5D%2FiSu'
         15        FETCH_OBJ_R                                      ~6      'cssMatcher'
         16        SEND_VAL                                                 ~6
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $7      
         19        ASSIGN                                                   !1, $7
  219    20        INIT_METHOD_CALL                                         'fromUtf8'
         21        SEND_VAR_EX                                              !1
         22        DO_FCALL                                      0  $9      
         23      > RETURN                                                   $9
  220    24*     > RETURN                                                   null

End of function escapecss

Function htmlattrmatcher:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 15, Position 2 = 17
Branch analysis from position: 15
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 25
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 34
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 45, Position 2 = 50
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 57
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
Branch analysis from position: 22
Branch analysis from position: 23
Branch analysis from position: 17
Branch analysis from position: 14
Branch analysis from position: 11
filename:       /in/RUq42
function name:  htmlAttrMatcher
number of ops:  63
compiled vars:  !0 = $matches, !1 = $chr, !2 = $ord, !3 = $hex
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  229     0  E >   RECV                                             !0      
  231     1        FETCH_DIM_R                                      ~4      !0, 0
          2        ASSIGN                                                   !1, ~4
  232     3        INIT_FCALL                                               'ord'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $6      
          6        ASSIGN                                                   !2, $6
  238     7        IS_SMALLER_OR_EQUAL                              ~8      !2, 31
          8      > JMPZ_EX                                          ~8      ~8, ->11
          9    >   IS_NOT_EQUAL                                     ~9      !1, '%09'
         10        BOOL                                             ~8      ~9
         11    > > JMPZ_EX                                          ~8      ~8, ->14
         12    >   IS_NOT_EQUAL                                     ~10     !1, '%0A'
         13        BOOL                                             ~8      ~10
         14    > > JMPZ_EX                                          ~8      ~8, ->17
         15    >   IS_NOT_EQUAL                                     ~11     !1, '%0D'
         16        BOOL                                             ~8      ~11
         17    > > JMPNZ_EX                                         ~8      ~8, ->23
  239    18    >   IS_SMALLER_OR_EQUAL                              ~12     127, !2
         19      > JMPZ_EX                                          ~12     ~12, ->22
         20    >   IS_SMALLER_OR_EQUAL                              ~13     !2, 159
         21        BOOL                                             ~12     ~13
         22    >   BOOL                                             ~8      ~12
         23    > > JMPZ                                                     ~8, ->25
  241    24    > > RETURN                                                   '%26%23xFFFD%3B'
  248    25    >   STRLEN                                           ~14     !1
         26        IS_SMALLER                                               1, ~14
         27      > JMPZ                                                     ~15, ->34
  249    28    >   INIT_METHOD_CALL                                         'convertEncoding'
         29        SEND_VAR_EX                                              !1
         30        SEND_VAL_EX                                              'UTF-16BE'
         31        SEND_VAL_EX                                              'UTF-8'
         32        DO_FCALL                                      0  $16     
         33        ASSIGN                                                   !1, $16
  252    34    >   INIT_FCALL                                               'bin2hex'
         35        SEND_VAR                                                 !1
         36        DO_ICALL                                         $18     
         37        ASSIGN                                                   !3, $18
  253    38        INIT_FCALL                                               'hexdec'
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                         $20     
         41        ASSIGN                                                   !2, $20
  254    42        FETCH_STATIC_PROP_IS                             ~22     'htmlNamedEntityMap'
         43        ISSET_ISEMPTY_DIM_OBJ                         0          ~22, !2
         44      > JMPZ                                                     ~23, ->50
  255    45    >   FETCH_STATIC_PROP_R          unknown             ~24     'htmlNamedEntityMap'
         46        FETCH_DIM_R                                      ~25     ~24, !2
         47        CONCAT                                           ~26     '%26', ~25
         48        CONCAT                                           ~27     ~26, '%3B'
         49      > RETURN                                                   ~27
  262    50    >   IS_SMALLER                                               255, !2
         51      > JMPZ                                                     ~28, ->57
  263    52    >   INIT_FCALL                                               'sprintf'
         53        SEND_VAL                                                 '%26%23x%2504X%3B'
         54        SEND_VAR                                                 !2
         55        DO_ICALL                                         $29     
         56      > RETURN                                                   $29
  265    57    >   INIT_FCALL                                               'sprintf'
         58        SEND_VAL                                                 '%26%23x%2502X%3B'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                         $30     
         61      > RETURN                                                   $30
  266    62*     > RETURN                                                   null

End of function htmlattrmatcher

Function jsmatcher:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RUq42
function name:  jsMatcher
number of ops:  32
compiled vars:  !0 = $matches, !1 = $chr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  275     0  E >   RECV                                             !0      
  277     1        FETCH_DIM_R                                      ~2      !0, 0
          2        ASSIGN                                                   !1, ~2
  278     3        STRLEN                                           ~4      !1
          4        IS_EQUAL                                                 ~4, 1
          5      > JMPZ                                                     ~5, ->14
  279     6    >   INIT_FCALL                                               'sprintf'
          7        SEND_VAL                                                 '%5Cx%2502X'
          8        INIT_FCALL                                               'ord'
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $6      
         11        SEND_VAR                                                 $6
         12        DO_ICALL                                         $7      
         13      > RETURN                                                   $7
  281    14    >   INIT_METHOD_CALL                                         'convertEncoding'
         15        SEND_VAR_EX                                              !1
         16        SEND_VAL_EX                                              'UTF-16BE'
         17        SEND_VAL_EX                                              'UTF-8'
         18        DO_FCALL                                      0  $8      
         19        ASSIGN                                                   !1, $8
  282    20        INIT_FCALL                                               'sprintf'
         21        SEND_VAL                                                 '%5Cu%2504s'
         22        INIT_FCALL                                               'strtoupper'
         23        INIT_FCALL                                               'bin2hex'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $10     
         26        SEND_VAR                                                 $10
         27        DO_ICALL                                         $11     
         28        SEND_VAR                                                 $11
         29        DO_ICALL                                         $12     
         30      > RETURN                                                   $12
  283    31*     > RETURN                                                   null

End of function jsmatcher

Function cssmatcher:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 11
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RUq42
function name:  cssMatcher
number of ops:  30
compiled vars:  !0 = $matches, !1 = $chr, !2 = $ord
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  292     0  E >   RECV                                             !0      
  294     1        FETCH_DIM_R                                      ~3      !0, 0
          2        ASSIGN                                                   !1, ~3
  295     3        STRLEN                                           ~5      !1
          4        IS_EQUAL                                                 ~5, 1
          5      > JMPZ                                                     ~6, ->11
  296     6    >   INIT_FCALL                                               'ord'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
         10      > JMP                                                      ->24
  298    11    >   INIT_METHOD_CALL                                         'convertEncoding'
         12        SEND_VAR_EX                                              !1
         13        SEND_VAL_EX                                              'UTF-16BE'
         14        SEND_VAL_EX                                              'UTF-8'
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                                   !1, $9
  299    17        INIT_FCALL                                               'hexdec'
         18        INIT_FCALL                                               'bin2hex'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $11     
         21        SEND_VAR                                                 $11
         22        DO_ICALL                                         $12     
         23        ASSIGN                                                   !2, $12
  301    24    >   INIT_FCALL                                               'sprintf'
         25        SEND_VAL                                                 '%5C%25X+'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $14     
         28      > RETURN                                                   $14
  302    29*     > RETURN                                                   null

End of function cssmatcher

Function toutf8:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
Branch analysis from position: 28
filename:       /in/RUq42
function name:  toUtf8
number of ops:  30
compiled vars:  !0 = $string, !1 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  312     0  E >   RECV                                             !0      
  314     1        INIT_METHOD_CALL                                         'getEncoding'
          2        DO_FCALL                                      0  $2      
          3        IS_IDENTICAL                                             $2, 'utf-8'
          4      > JMPZ                                                     ~3, ->7
  315     5    >   ASSIGN                                                   !1, !0
          6      > JMP                                                      ->15
  317     7    >   INIT_METHOD_CALL                                         'convertEncoding'
          8        SEND_VAR_EX                                              !0
          9        SEND_VAL_EX                                              'UTF-8'
         10        INIT_METHOD_CALL                                         'getEncoding'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR_

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
270.74 ms | 1428 KiB | 36 Q