You are here

private function JavaScriptPacker::_encodeSpecialChars in Advanced CSS/JS Aggregation 7

Same name and namespace in other branches
  1. 8.4 advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  2. 8.2 advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  3. 8.3 advagg_js_minify/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  4. 6 advagg_js_compress/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()
  5. 7.2 advagg_js_compress/jspacker.inc \JavaScriptPacker::_encodeSpecialChars()

File

advagg_js_compress/jspacker.inc, line 155

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);
}