Same name in other branches
  1. 5.0.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  2. 6.0.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  3. 7.x-1.x advagg_js_compress/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  4. 7.x-2.x advagg_js_compress/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  5. 8.x-3.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  6. 8.x-4.x advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()

File

advagg_js_minify/jspacker.inc, line 171

Class

JavaScriptPacker

Code

private function _encodeSpecialChars($script) {
    $parser = new ParseMaster();
    // replace: $name -> n, $$name -> na
    $parser->add('/((\\x24+)([a-zA-Z$_]+))(\\d*)/', array(
        'fn' => '_replace_name',
    ));
    // replace: _name -> _0, double-underscore (__name) is ignored
    $regexp = '/\\b_[A-Za-z\\d]\\w*/';
    // build the word list
    $keywords = $this->_analyze($script, $regexp, '_encodePrivate');
    // quick ref
    $encoded = $keywords['encoded'];
    $parser->add($regexp, array(
        'fn' => '_replace_encoded',
        'data' => $encoded,
    ));
    return $parser->exec($script);
}