Commit 66f8ca41 by Takumi Imai

ビルドテストコミット

parent 7ea8588b
#Pack (July 2005)
# Based on "Pack.js" by Dean Edwards <http://dean.edwards.name/>
# Ported to Perl by Rob Seiler, ELR Software Pty Ltd <http://www.elr.com.au>
# Copyright 2005. License <http://creativecommons.org/licenses/LGPL/2.1/>
package Pack;
use strict;
use Data::Dumper;
use ParseMaster;
# Package wide variable declarations
use vars qw/$VERSION $PM_VERSION
$_X_encodePrivate $_JSunpack $_JSdecode %baseLookup
$_X_encode10 $_X_encode36 $_X_encode62 $_X_encode95
$_JSencode10 $_JSencode36 $_JSencode62 $_JSencode95
@_X_parsers
$_X_script $_X_encoding $_X_fastDecode $_X_specialChars
/;
$VERSION = '024';
$PM_VERSION = $ParseMaster::VERSION;
# Package wide constants
my $X_IGNORE = q{$1};
my $X_ENCODE = q/\x24encode\(\x24count\)/; # NB: requires g modifier
my $PERL = 'perl'; # Flag to indicate whether we need to use one of our "internal" Perl encoding functions
my $JSCRIPT = 'jscript'; # or embed a pre-build JScript encoding function
########################################
##################
sub pack($$$$) { # require 4 arguments
##################
#print Dumper(@_);
($_X_script, $_X_encoding, $_X_fastDecode, $_X_specialChars) = @_;
# validate parameters (sort of!)
$_X_script .= "\n";
$_X_encoding = ($_X_encoding > 95) ? 95 : $_X_encoding;
@_X_parsers = (); # Reset parsers
####################
sub _X_pack($) { # require 1 argument
####################
# apply all parsing routines
my $X_script = shift;
for (my $i = 0; $i<scalar(@_X_parsers); $i++) {
my $X_parse = $_X_parsers[$i];
$X_script = &$X_parse($X_script);
}
return $X_script;
};
######################
sub _X_addParser { #
######################
# keep a list of parsing functions, they'll be executed all at once
my $X_parser = shift;
push (@_X_parsers,$X_parser);
}
#############################
sub _X_basicCompression { #
#############################
# zero encoding - just removal of white space and comments
my $X_script = shift;
my $parser = ParseMaster->new();
# make safe
$parser->escapeChar("\\");
# protect strings
$parser->add(q/'[^'\n\r]*'/, $X_IGNORE);
$parser->add(q/"[^"\n\r]*"/, $X_IGNORE);
# remove comments
$parser->add(q/\/\/[^\n\r]*[\n\r]/);
$parser->add(q/\/\*[^*]*\*+([^\/][^*]*\*+)*\//);
# protect regular expressions
$parser->add(q/\s+(\/[^\/\n\r\*][^\/\n\r]*\/g?i?)/, q{$2}); # IGNORE
$parser->add(q/[^\w\x24\/'"*)\?:]\/[^\/\n\r\*][^\/\n\r]*\/g?i?/, $X_IGNORE);
# remove: ;;; doSomething();
$parser->add(q/;;[^\n\r]+[\n\r]/) if ($_X_specialChars);
# remove redundant semi-colons
$parser->add(q/;+\s*([};])/, q{$2});
# remove white-space
$parser->add(q/(\b|\x24)\s+(\b|\x24)/, q{$2 $3});
$parser->add(q/([+\-])\s+([+\-])/, q{$2 $3});
$parser->add(q/\s+/, '');
# done
return $parser->exec($X_script);
}
###############################
sub _X_encodeSpecialChars { #
###############################
my $X_script = shift;
my $parser = ParseMaster->new();
# replace: $name -> n, $$name -> $$na
$parser->add(q/((\x24+)([a-zA-Z\x24_]+))(\d*)/,
sub {
my $X_offset = pop;
my @X_match = @_;
my $X_length = length($X_match[$X_offset+2]);
my $lengthnext = length($X_match[$X_offset+3]);
my $X_start = $X_length - ((($X_length - $lengthnext) > 0) ? ($X_length - $lengthnext) : 0);
my $str = $X_match[$X_offset+1];
$str = substr($str,$X_start,$X_length) . $X_match[$X_offset+4];
return "$str";
});
# replace: _name -> _0, double-underscore (__name) is ignored
my $X_regexp = q/\b_[A-Za-z\d]\w*/;
# build the word list
my %X_keywords = &_X_analyze($X_script, $X_regexp, $_X_encodePrivate);
#print Dumper(%X_keywords);
# quick ref
my $X_encoded = \$X_keywords{X_encoded}; # eg _private1 => '_0',_private2 => '_1';
#print Dumper($X_encoded);
$parser->add($X_regexp, sub {my $X_offset = pop; my @X_match = @_; return ${$X_encoded}->{$X_match[$X_offset]};});
return $parser->exec($X_script);
};
###########################
sub _X_encodeKeywords { #
###########################
my $X_script = shift;
# escape high-ascii values already in the script (i.e. in strings)
if ($_X_encoding > 62) {$X_script = &_X_escape95($X_script)};
# create the parser
my $parser = ParseMaster->new();
my $X_encode = &_X_getEncoder($_X_encoding,$PERL);
# for high-ascii, don't encode single character low-ascii
my $X_regexp = ($_X_encoding > 62) ? q/\w\w+/ : q/\w+/;
# build the word list
my %X_keywords = &_X_analyze($X_script, $X_regexp, $X_encode);
#print Dumper(%X_keywords);
my $X_encoded = \$X_keywords{X_encoded}; # eg alert => 2, function => 10 etc
# encode
$parser->add($X_regexp, sub {my $X_offset = pop; my @X_match = @_; return ${$X_encoded}->{$X_match[$X_offset]};});
# if encoded, wrap the script in a decoding function
return $X_script && _X_bootStrap(\$parser->exec($X_script), \%X_keywords);
}
####################
sub _X_analyze { #
####################
#print Dumper(@_);
my ($X_script, $X_regexp, $X_encode) = @_;
# analyse
# retreive all words in the script
my @X_all = $X_script =~ m/$X_regexp/g; # Save all captures in a list context
my %XX_sorted = (); # list of words sorted by frequency
my %XX_encoded = (); # dictionary of word->encoding
my %XX_protected = (); # instances of "protected" words
if (@X_all) {
my @X_unsorted = (); # same list, not sorted
my %X_protected = (); # "protected" words (dictionary of word->"word")
my %X_values = (); # dictionary of charCode->encoding (eg. 256->ff)
my %X_count = (); # word->count
my $i = scalar(@X_all); my $j = 0; my $X_word = '';
# count the occurrences - used for sorting later
do {
$X_word = '$' . $X_all[--$i];
if (!exists($X_count{$X_word})) {
$X_count{$X_word} = [0,$i]; # Store both the usage count and original array position (ie a secondary sort key)
$X_unsorted[$j] = $X_word;
# make a dictionary of all of the protected words in this script
# these are words that might be mistaken for encoding
$X_values{$j} = &$X_encode($j);
my $v = '$'.$X_values{$j};
$X_protected{$v} = $j++;
}
# increment the word counter
$X_count{$X_word}[0]++;
} while ($i);
#print Dumper (%X_values);
#print Dumper (@X_unsorted);
#print Dumper (%X_protected);
# prepare to sort the word list, first we must protect
# words that are also used as codes. we assign them a code
# equivalent to the word itself.
# e.g. if "do" falls within our encoding range
# then we store keywords["do"] = "do";
# this avoids problems when decoding
$i = scalar(@X_unsorted);
do {
$X_word = $X_unsorted[--$i];
if (exists($X_protected{$X_word})) {
$XX_sorted{$X_protected{$X_word}} = substr($X_word,1);
$XX_protected{$X_protected{$X_word}} = 1; # true
$X_count{$X_word}[0] = 0;
}
} while ($i);
#print Dumper (%XX_protected);
#print Dumper (%XX_sorted);
#print Dumper (%X_count);
# sort the words by frequency
# Sort with count a primary key and original array order as secondary key - which is apparently the default in javascript!
@X_unsorted = sort ({($X_count{$b}[0] - $X_count{$a}[0]) or ($X_count{$b}[1] <=> $X_count{$a}[1])} @X_unsorted);
#print Dumper (@X_unsorted) . "\n";
$j = 0;
# because there are "protected" words in the list
# we must add the sorted words around them
do {
if (!exists($XX_sorted{$i})) {$XX_sorted{$i} = substr($X_unsorted[$j++],1)}
$XX_encoded{$XX_sorted{$i}} = $X_values{$i};
} while (++$i < scalar(@X_unsorted));
}
#print Dumper(X_sorted => \%XX_sorted, X_encoded => \%XX_encoded, X_protected => \%XX_protected);
return (X_sorted => \%XX_sorted, X_encoded => \%XX_encoded, X_protected => \%XX_protected);
}
######################
sub _X_bootStrap { #
######################
# build the boot function used for loading and decoding
my ($X_packed, $X_keywords) = @_; # Reference arguments!
#print Dumper ($X_keywords) . "\n";
# $packed: the packed script - dereference and escape
$X_packed = "'" . &_X_escape($$X_packed) ."'";
my %sorted = %{$$X_keywords{X_sorted}}; # Dereference to local variables
my %protected = %{$$X_keywords{X_protected}}; # for simplicity
my @sorted = ();
foreach my $key (keys %sorted) {$sorted[$key] = $sorted{$key}}; # Convert hash to a standard list
# ascii: base for encoding
my $X_ascii = ((scalar(@sorted) > $_X_encoding) ? $_X_encoding : scalar(@sorted)) || 1;
# count: number of (unique {RS}) words contained in the script
my $X_count = scalar(@sorted); # Use $X_count for assigning $X_ascii
# keywords: list of words contained in the script
foreach my $i (keys %protected) {$sorted[$i] = ''}; # Blank out protected words
#print Dumper(@sorted) . "\n";
# convert from a string to an array - prepare keywords as a JScript string->array {RS}
$X_keywords = "'" . join('|',@sorted) . "'.split('|')";
# encode: encoding function (used for decoding the script)
my $X_encode = $_X_encoding > 62 ? $_JSencode95 : &_X_getEncoder($X_ascii,$JSCRIPT); # This is a JScript function (as a string)
$X_encode =~ s/_encoding/\x24ascii/g; $X_encode =~ s/arguments\.callee/\x24encode/g;
my $X_inline = '$count' . ($X_ascii > 10 ? '.toString($ascii)' : '');
# decode: code snippet to speed up decoding
my $X_decode = '';
if ($_X_fastDecode) {
# create the decoder
$X_decode = &_X_getFunctionBody($_JSdecode); # ie from the Javascript literal function
if ($_X_encoding > 62) {$X_decode =~ s/\\\\w/[\\xa1-\\xff]/g}
# perform the encoding inline for lower ascii values
elsif ($X_ascii < 36) {$X_decode =~ s/$X_ENCODE/$X_inline/g}
# special case: when $X_count==0 there ar no keywords. i want to keep
# the basic shape of the unpacking funcion so i'll frig the code...
if (!$X_count) {$X_decode =~ s/(\x24count)\s*=\s*1/$1=0/}
}
# boot function
my $X_unpack = $_JSunpack;
if ($_X_fastDecode) {
# insert the decoder
$X_unpack =~ s/\{/\{$X_decode;/;
}
$X_unpack =~ s/"/'/g;
if ($_X_encoding > 62) { # high-ascii
# get rid of the word-boundaries for regexp matches
$X_unpack =~ s/'\\\\b'\s*\+|\+\s*'\\\\b'//g; # Not checked! {RS}
}
if ($X_ascii > 36 || $_X_encoding > 62 || $_X_fastDecode) {
# insert the encode function
$X_unpack =~ s/\{/\{\$encode=$X_encode;/;
} else {
# perform the encoding inline
$X_unpack =~ s/$X_ENCODE/$X_inline/;
}
# arguments {RS} Do this before using &pack because &pack changes the pack parameters (eg $fastDecode) in Perl!!
my $X_params = "$X_packed,$X_ascii,$X_count,$X_keywords"; # Interpolate to comma separated string
if ($_X_fastDecode) {
# insert placeholders for the decoder
$X_params .= ',0,{}';
}
# pack the boot function too
$X_unpack = &pack($X_unpack,0,0,1);
# the whole thing
return "eval(" . $X_unpack . "(" . $X_params . "))\n";
};
#######################
sub _X_getEncoder { #
#######################
# mmm.. ..which one do i need ?? ({RS} Perl or JScript ??)
my ($X_ascii,$language) = @_;
my $perl_encoder = ($X_ascii > 10) ? ($X_ascii > 36) ? ($X_ascii > 62) ? $_X_encode95 : $_X_encode62 : $_X_encode36 : $_X_encode10;
my $jscript_encoder = ($X_ascii > 10) ? ($X_ascii > 36) ? ($X_ascii > 62) ? $_JSencode95 : $_JSencode62 : $_JSencode36 : $_JSencode10;
return ($language eq $JSCRIPT) ? $jscript_encoder : $perl_encoder;
};
#############################
# Perl versions of encoders #
#############################
# base10 zero encoding - characters: 0123456789
$_X_encode10 = sub {return &_encodeBase(shift,10)};
# base36 - characters: 0123456789abcdefghijklmnopqrstuvwxyz
$_X_encode36 = sub {return &_encodeBase(shift,36)};
# base62 - characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
$_X_encode62 = sub {return &_encodeBase(shift,62)};
# high-ascii values - characters: ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ
$_X_encode95 = sub {return &_encodeBase(shift,95)};
# Lookup character sets for baseN encoding
$baseLookup{10} = [(0..9)[0..9]]; # base 10
$baseLookup{36} = [(0..9,'a'..'z')[0..35]]; # base 36
$baseLookup{62} = [(0..9,'a'..'z','A'..'Z')[0..61]]; # base 62
$baseLookup{95} = (); for (my $i=0; $i<95; $i++) {$baseLookup{95}[$i] = chr($i+161)}; # base95 (high ascii)
#print Dumper(%baseLookup);
#####################
sub _encodeBase { #
#####################
# Generic base conversion function using defined lookup arrays (perl version only)
my ($X_charCode, $base) = @_;
my $X_encoded = '';
# Do we know this encoding?
if (exists ($baseLookup{$base})) {
if ($X_charCode == 0) {$X_encoded = $baseLookup{$base}[0]}
while($X_charCode > 0) {
$X_encoded = $baseLookup{$base}[$X_charCode % $base] . $X_encoded;
$X_charCode = int($X_charCode / $base);
}
}
else {$X_encoded = "$X_charCode"} # default is to return unchanged (ie as for base 10) if no baselookup is available
return $X_encoded;
};
#############################
$_X_encodePrivate = sub { #
#############################
# special _chars
my $X_charCode = shift;
return '_' . $X_charCode;
};
############################
sub _X_escape($script) { #
############################
# protect characters used by the parser
my $X_script = shift;
$X_script =~ s/([\\'])/\\$1/g;
return $X_script;
};
#####################
sub _X_escape95 { #
#####################
# protect high-ascii characters already in the script
my $X_script = shift;
$X_script =~ s/([\xa1-\xff])/sprintf("\\x%1x",ord($1))/eg;
return $X_script;
};
############################
sub _X_getFunctionBody { #
############################
# extract the body of a function (ie between opening/closing {}) - consistent with Dean Edwards approach
my $X_function = shift;
$X_function =~ m/^.*\{(.*)\}*$/sg; # Multiline, global (greedy)
my $start = index($X_function,'{');
my $end = rindex($X_function,'}');
$X_function = substr($X_function,($start+1),($end-1-$start));
return $X_function;
};
######################
sub _X_globalize { #
######################
# set the global flag on a RegExp (you have to create a new one) !!! Unused in perl version
# my $X_regexp = shift;
};
# build the parsing routine
&_X_addParser(\&_X_basicCompression);
&_X_addParser(\&_X_encodeSpecialChars) if ($_X_specialChars);
&_X_addParser(\&_X_encodeKeywords) if ($_X_encoding);
# go!
return &_X_pack($_X_script);
}
########################
# Javascript Literals #
########################
# JScript function "_unpack" - from DeanEdwards pack.js (NB: No ";" after final "}")
($_JSunpack) = <<'END_JSCRIPT_UNPACK';
/* unpacking function - this is the boot strap function */
/* data extracted from this packing routine is passed to */
/* this function when decoded in the target */
function($packed, $ascii, $count, $keywords, $encode, $decode) {
while ($count--)
if ($keywords[$count])
$packed = $packed.replace(new RegExp('\\b' + $encode($count) + '\\b', 'g'), $keywords[$count]);
/* RS_Debug = $packed; */ /* {RS} !!!!!!!!! */
return $packed;
}
END_JSCRIPT_UNPACK
# JScript function "_decode" - from DeanEdwards pack.js
($_JSdecode) = <<'END_JSCRIPT_DECODE';
/* code-snippet inserted into the unpacker to speed up decoding */
function() {
/* does the browser support String.replace where the */
/* replacement value is a function? */
if (!''.replace(/^/, String)) {
/* decode all the values we need */
while ($count--) $decode[$encode($count)] = $keywords[$count] || $encode($count);
/* global replacement function */
$keywords = [function($encoded){return $decode[$encoded]}];
/* generic match */
$encode = function(){return'\\w+'};
/* reset the loop counter - we are now doing a global replace */
$count = 1;
}
};
END_JSCRIPT_DECODE
# JScript versions of encoders
($_JSencode10) = <<'END_JSCRIPT_ENCODE10';
/* zero encoding */
/* characters: 0123456789 */
function($charCode) {
return $charCode;
};
END_JSCRIPT_ENCODE10
($_JSencode36) = <<'END_JSCRIPT_ENCODE36';
/* inherent base36 support */
/* characters: 0123456789abcdefghijklmnopqrstuvwxyz */
function($charCode) {
return $charCode.toString(36);
};
END_JSCRIPT_ENCODE36
($_JSencode62) = <<'END_JSCRIPT_ENCODE62';
/* hitch a ride on base36 and add the upper case alpha characters */
/* characters: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ */
function($charCode) {
return ($charCode < _encoding ? '' : arguments.callee(parseInt($charCode / _encoding))) +
(($charCode = $charCode % _encoding) > 35 ? String.fromCharCode($charCode + 29) : $charCode.toString(36));
};
END_JSCRIPT_ENCODE62
($_JSencode95) = <<'END_JSCRIPT_ENCODE95';
/* use high-ascii values */
/* characters: ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ */
function($charCode) {
return ($charCode < _encoding ? '' : arguments.callee($charCode / _encoding)) +
String.fromCharCode($charCode % _encoding + 161);
};
END_JSCRIPT_ENCODE95
###########
# END #
###########
1; # Pack #
###########
#ParseMaster (July 25 2005)
# Based on "ParseMaster.js" by Dean Edwards <http://dean.edwards.name/>
# Ported to Perl by Rob Seiler, ELR Software Pty Ltd <http://www.elr.com.au>
# Copyright 2005. License <http://creativecommons.org/licenses/LGPL/2.1/>
package ParseMaster;
use strict;
use Data::Dumper;
# Package wide variable declarations
use vars qw/$VERSION
@_X_escaped @_X_patterns
/;
$VERSION = '017';
# constants
my $X_EXPRESSION = 0;
my $X_REPLACEMENT = 1;
my $X_LENGTH = 2;
# re's used to determine nesting levels
my $X_GROUPS = qr/\(/o; # NB: Requires g modifier!
my $X_SUB_REPLACE = qr/\$\d/o;
my $X_INDEXED = qr/^\$\d+$/o;
my $XX_ESCAPE = qr/\\./o; # NB: Requires g modifier!
my $XX_DELETED = qr/\001[^\001]*\001/o; # NB: Requires g modifier!
my $DIGIT = qr/[^\D]/o; # Yep - this is a digit - contains no non-digits
# Constructor
sub new {
my $class = shift;
my $self = {};
@_X_escaped = (); # Re-initialize global for each instance
@_X_patterns = (); # Re-initialize global for each instance
# Instance variables - access by similarly named set/get functions
$self->{_ignoreCase_} = 0;
$self->{_escapeChar_} = '';
bless ($self, $class);
return $self;
}
sub ignoreCase {
my ($self, $value) = @_;
if (defined($value)) {
$self->{_ignoreCase_} = $value;
}
return $self->{_ignoreCase_};
}
sub escapeChar{
my ($self, $value) = @_;
if (defined($value)) {
$self->{_escapeChar_} = $value;
}
return $self->{_escapeChar_};
}
#######################
# Public Parsemaster functions
my $X_DELETE = sub(@$) {
my $X_offset = pop;
my @X_match = @_;
return (chr(001) . $X_match[$X_offset] . chr(001));
}; # NB semicolon required for closure!
# create and add a new pattern to the patterns collection
sub add {
my ($self, $expression, $X_replacement) = @_;
if (!$X_replacement) {$X_replacement = $X_DELETE};
# count the number of sub-expressions
my $temp = &_X_internalEscape($expression);
my $length = 1; # Always at least one because each pattern is itself a sub-expression
$length += $temp =~ s/$X_GROUPS//g; # One way to count the left capturing parentheses in the regexp string
# does the pattern deal with sub-expressions?
if ((ref($X_replacement) ne "CODE") && ($X_replacement =~ m/$X_SUB_REPLACE/)) {
if ($X_replacement =~ m/$X_INDEXED/) { # a simple lookup? (eg "$2")
# store the index (used for fast retrieval of matched strings)
$X_replacement = substr($X_replacement,1) - 1;
}
else { # a complicated lookup (eg "Hello $2 $1")
my $i = $length;
while ($i) { # Had difficulty getting Perl to do Dean's splitting and joining of strings containing $'s
my $str = '$a[$o+' . ($i-1) . ']'; # eg $a[$o+1]
$X_replacement =~ s/\$$i/$str/; # eg $2 $3 -> $a[$o+1] $a[$o+2]
$i--;
}
# build a function to do the lookup - returns interpolated string of array lookups
$X_replacement = eval('sub {my $o=pop; my @a=@_; return "' . $X_replacement . '"};');
}
}
else {}
# pass the modified arguments
&_X_add($expression || q/^$/, $X_replacement, $length);
}
# execute the global replacement
sub exec {
#print Dumper(@_X_patterns);
my ($self, $X_string) = @_;
my $escChar = $self->escapeChar();
my $ignoreCase = $self->ignoreCase();
my ($regexp,$captures) = &_getPatterns(); # Concatenated and parenthesized regexp eg '(regex1)|(regex2)|(regex3)' etc
$X_string = &_X_escape($X_string, $escChar);
if ($ignoreCase) {$X_string =~ s/$regexp/{&_X_replacement(&_matchVars($captures,\$X_string))}/gie} # Pass $X_String as a
else {$X_string =~ s/$regexp/{&_X_replacement(&_matchVars($captures,\$X_string))}/ge} # reference for speed
$X_string = &_X_unescape($X_string, $escChar);
$X_string =~ s/$XX_DELETED//g;
return $X_string;
}
sub _X_add {
push (@_X_patterns, [@_]); # Save each argument set as is into an array of arrays
}
# this is the global replace function (it's quite complicated)
sub _X_replacement {
my (@arguments) = @_;
#print Dumper (@arguments);
if ($arguments[0] le '') {return ''}
# Dereference last index (source String) here - faster than in _matchVars (maybe not needed at all?)
$arguments[$#arguments] = ${$arguments[$#arguments]};
my $i = 1;
# loop through the patterns
for (my $j=0; $j<scalar(@_X_patterns); $j++) { # Loop through global all @_X_patterns
my @X_pattern = @{$_X_patterns[$j]};
# do we have a result? NB: "if ($arguments[$i])" as in Dean's Javascript is false for the value 0!!!
if ((defined $arguments[$i]) && ($arguments[$i] gt '')) {
my $X_replacement = $X_pattern[$X_REPLACEMENT];
# switch on type of $replacement
if (ref($X_replacement) eq "CODE") { # function
return &$X_replacement(@arguments,$i);
}
elsif ($X_replacement =~ m/$DIGIT/) { # number (contains no non-digits)
return $arguments[$X_replacement + $i];
}
else { # default
return $X_replacement; # default
}
} # skip over references to sub-expressions
else {$i += $X_pattern[$X_LENGTH]}
}
}
#######################
# Private functions
#######################
# encode escaped characters
sub _X_escape {
my ($X_string, $X_escapeChar) = @_;
if ($X_escapeChar) {
my $re = '\\'.$X_escapeChar.'(.)';
$X_string =~ s/$re/{push(@_X_escaped,$1); $X_escapeChar}/ge;
}
return $X_string;
}
# decode escaped characters
sub _X_unescape {
my ($X_string, $X_escapeChar) = @_;
if ($X_escapeChar) { # We'll only do this if there is an $X_escapeChar!
my $re = '\\'.$X_escapeChar;
$X_string =~ s/$re/{$X_escapeChar . (shift(@_X_escaped))}/ge; # Don't use Dean Edwards as below 'or' here - because zero will return ''!
# $X_string =~ s/$re/{$X_escapeChar . (shift(@_X_escaped) || '')}/ge;
}
return $X_string;
}
sub _X_internalEscape {
my ($string) = shift;
$string =~ s/$XX_ESCAPE//g;
return $string;
}
# Builds an array of match variables to (approximately) emulate that available in Javascript String.replace()
sub _matchVars {
my ($m,$sref) = @_;
my @args = (1..$m); # establish the number potential memory variables
my @mv = map {eval("\$$_")} @args; # matchvarv[1..m] = the memory variables $1 .. $m
unshift (@mv, $&); # matchvar[0] = the substring that matched
push (@mv, length($`)); # matchvar[m+1] = offset within the source string where the match occurred (= length of prematch string)
push (@mv, $sref); # matchvar[m+2] = reference to full source string (dereference in caller if/when needed)
#print Dumper (@mv);
return @mv;
}
sub _getPatterns {
my @Patterns = ();
my $lcp = 0;
for (my $i=0; $i<scalar(@_X_patterns); $i++) { # Loop through global all @_patterns
push (@Patterns, $_X_patterns[$i][$X_EXPRESSION]); # accumulate the expressions
$lcp += $_X_patterns[$i][$X_LENGTH]; # sum the left capturing parenthesis counts
}
my $str = "(" . join(')|(',@Patterns). ")"; # enclose each pattern in () separated by "|"
return ($str, $lcp);
}
##################
# END #
##################
1; # ParseMaster #
##################
#!perl
#
use strict;
use Pack;
use vars qw/$VERSION/;
$VERSION = '1.01b';
my $Version = "v$VERSION\[p$Pack::VERSION-pm$Pack::PM_VERSION\]";
if ((!$ARGV[0]) || ($ARGV[0] ne '-o')) {
print "$0 $Version\n";
print " This program generates an html page containing examples of packed Javascript\n";
print "\tSyntax: $0 -o > testpage.htm\n";
exit(1);
}
# Get the javascript to be packed
my $libraryscript = getJSLibrary(); # eg a library - could be from an external file
my @blockscripts = getJSBlocks(); # eg local blocks specific to this page
# Set pack options (extend with cgi interface etc)
my $encoding = 62;
my $fastdecoding = 1;
my $specialcharacters = 1;
# Pack the source scripts
my $packedlibrary = &Pack::pack($libraryscript, $encoding, $fastdecoding, $specialcharacters);
my @packedblocks = ();
for (my $i=0; $i< scalar(@blockscripts); $i++) { # Pack each indexed block of js code
$packedblocks[$i] = &Pack::pack($blockscripts[$i], $encoding, $fastdecoding, $specialcharacters);
}
# Output the html page containing the packed scripts (passed by reference in this case)
#print "Content-type: text/html\n\n";
printHTMLPage(\$packedlibrary,\@packedblocks);
##########
# End #
exit(0); #
##########
################
# Sub-routines #
################
#############
# HTML PAGE #
#############
sub printHTMLPage {
my ($libraryref,$blocksref) = @_; # References to packed scripts - need to be de-referenced in interpolations
my ($HTML) = <<"END_HTML";
<html><head><title>Packed script example page</title>
<!-- Here is where the library script is inserted -->
<script language="JavaScript">$$libraryref</script>
<!-->
</head><body>
<center>
<h1>Packed Javascript</h1>
<p>
Javascript contained within this page has been packed using using <br>
Packer [$0] $Version<br>
a JavaScript Compressor/Obfuscator developed by Dean Edwards <<a href="http://dean.edwards.name/">http://dean.edwards.name/</a>><br>
and ported to Perl by Rob Seiler, ELR Software Pty Ltd <<a href="http://www.elr.com.au/">http://www.elr.com.au</a>><br>
Copyright 2005. License <a href="http://creativecommons.org/licenses/LGPL/2.1/">http://creativecommons.org/licenses/LGPL/2.1/</a>>
</p>
</center>
<h2>Profile of your Browser</h2>
<p>Here are the results of running the packed JavaScript code in the browser you are using.
If you are seeing bowser vendor, version, and operating system data, the packed scripts are functioning properly.</p>
<!-- Here is where the local block scripts are inserted -->
<h3>Bascic Data</h3> <script language="JavaScript">$$blocksref[0]</script>
<h3>Version Number</h3> <script language="JavaScript">$$blocksref[1]</script>
<h3>Browser Version</h3> <script language="JavaScript">$$blocksref[2]</script>
<h3>JavaScript Version</h3><script language="JavaScript">$$blocksref[3]</script>
<h3>OS</h3> <script language="JavaScript">$$blocksref[4]</script>
<!-->
</body></html>
END_HTML
print $HTML;
}
#############################
# Javascript Source Scripts #
#############################
# Below are our example Javascript code blocks
sub getJSLibrary {
my ($jscript) = <<'END_JSLIBRARY';
// Ultimate client-side JavaScript client sniff.
// (C) Netscape Communications 1999. Permission granted to reuse and distribute.
// Revised 7 May 99 to add is.nav5up and is.ie5up (see below). (see below).
// Everything you always wanted to know about your JavaScript client
// but were afraid to ask ... "Is" is the constructor function for "is" object,
// which has properties indicating:
// (1) browser vendor:
// is.nav, is.ie, is.opera
// (2) browser version number:
// is.major (integer indicating major version number: 2, 3, 4 ...)
// is.minor (float indicating full version number: 2.02, 3.01, 4.04 ...)
// (3) browser vendor AND major version number
// is.nav2, is.nav3, is.nav4, is.nav4up, is.ie3, is.ie4, is.ie4up, is.ie5, is.ie5up
// (4) JavaScript version number:
// is.js (float indicating full JavaScript version number: 1, 1.1, 1.2 ...)
// (5) OS platform and version:
// is.win, is.win16, is.win32, is.win31, is.win95, is.winnt, is.win98
// is.os2
// is.mac, is.mac68k, is.macppc
// is.unix
// is.sun, is.sun4, is.sun5, is.suni86
// is.irix, is.irix5, is.irix6
// is.hpux, is.hpux9, is.hpux10
// is.aix, is.aix1, is.aix2, is.aix3, is.aix4
// is.linux, is.sco, is.unixware, is.mpras, is.reliant
// is.dec, is.sinix, is.freebsd, is.bsd
// is.vms
//
// See http://www.it97.de/JavaScript/JS_tutorial/bstat/navobj.html and
// http://www.it97.de/JavaScript/JS_tutorial/bstat/Browseraol.html
// for detailed lists of userAgent strings.
//
// Note: you don't want your Nav4 or IE4 code to "turn off" or
// stop working when Nav5 and IE5 (or later) are released, so
// in conditional code forks, use is.nav4up ("Nav4 or greater")
// and is.ie4up ("IE4 or greater") instead of is.nav4 or is.ie4
// to check version in code which you want to work on future
// versions.
function Is ()
{ // convert all characters to lowercase to simplify testing
var agt=navigator.userAgent.toLowerCase();
// *** BROWSER VERSION ***
// Note: On IE5, these return 4, so use is.ie5up to detect IE5.
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1));
this.nav2 = (this.nav && (this.major == 2));
this.nav3 = (this.nav && (this.major == 3));
this.nav4 = (this.nav && (this.major == 4));
this.nav4up = (this.nav && (this.major >= 4));
this.navonly = (this.nav && ((agt.indexOf(";nav") != -1) ||
(agt.indexOf("; nav") != -1)) );
this.nav5 = (this.nav && (this.major == 5));
this.nav5up = (this.nav && (this.major >= 5));
this.ie = (agt.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));
this.ie4 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")==-1) );
this.ie4up = (this.ie && (this.major >= 4));
this.ie5 = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) );
this.ie5up = (this.ie && !this.ie3 && !this.ie4);
this.aol = (agt.indexOf("aol") != -1);
this.aol3 = (this.aol && this.ie3);
this.aol4 = (this.aol && this.ie4);
this.opera = (agt.indexOf("opera") != -1);
this.webtv = (agt.indexOf("webtv") != -1);
// *** JAVASCRIPT VERSION CHECK ***
// Useful to workaround Nav3 bug in which Nav3
// loads <SCRIPT LANGUAGE="JavaScript1.2">
if (this.nav2 || this.ie3) this.js = 1.0;
else if (this.nav3 || this.opera) this.js = 1.1;
else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2;
else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3;
else if (this.nav5) this.js = 1.4;
// NOTE: In the future, update this code when newer versions of JS
// are released. For now, we try to provide some upward compatibility
// so that future versions of Nav and IE will show they are at
// *least* JS 1.x capable. Always check for JS version compatibility
// with > or >=.
else if (this.nav && (this.major > 5)) this.js = 1.4;
else if (this.ie && (this.major > 5)) this.js = 1.3;
// HACK: no idea for other browsers; always check for JS version with > or >=
else this.js = 0.0;
// *** PLATFORM ***
this.win = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
// NOTE: On Opera 3.0, the userAgent string includes "Windows 95/NT4" on all
// Win32, so you can't distinguish between Win95 and WinNT.
this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1));
// is this a 16 bit compiled version?
this.win16 = ((agt.indexOf("win16")!=-1) ||
(agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) ||
(agt.indexOf("windows 16-bit")!=-1) );
this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) ||
(agt.indexOf("windows 16-bit")!=-1));
// NOTE: Reliable detection of Win98 may not be possible. It appears that:
// - On Nav 4.x and before you'll get plain "Windows" in userAgent.
// - On Mercury client, the 32-bit version will return "Win98", but
// the 16-bit version running on Win98 will still return "Win95".
this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1));
this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1));
this.win32 = ( this.win95 || this.winnt || this.win98 ||
((this.major >= 4) && (navigator.platform == "Win32")) ||
(agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1) );
this.os2 = ((agt.indexOf("os/2")!=-1) ||
(navigator.appVersion.indexOf("OS/2")!=-1) ||
(agt.indexOf("ibm-webexplorer")!=-1));
this.mac = (agt.indexOf("mac")!=-1);
this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) ||
(agt.indexOf("68000")!=-1)));
this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) ||
(agt.indexOf("powerpc")!=-1)));
this.sun = (agt.indexOf("sunos")!=-1);
this.sun4 = (agt.indexOf("sunos 4")!=-1);
this.sun5 = (agt.indexOf("sunos 5")!=-1);
this.suni86= (this.sun && (agt.indexOf("i86")!=-1));
this.irix = (agt.indexOf("irix") !=-1); // SGI
this.irix5 = (agt.indexOf("irix 5") !=-1);
this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1));
this.hpux = (agt.indexOf("hp-ux")!=-1);
this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1));
this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1));
this.aix = (agt.indexOf("aix") !=-1); // IBM
this.aix1 = (agt.indexOf("aix 1") !=-1);
this.aix2 = (agt.indexOf("aix 2") !=-1);
this.aix3 = (agt.indexOf("aix 3") !=-1);
this.aix4 = (agt.indexOf("aix 4") !=-1);
this.linux = (agt.indexOf("inux")!=-1);
this.sco = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1);
this.unixware = (agt.indexOf("unix_system_v")!=-1);
this.mpras = (agt.indexOf("ncr")!=-1);
this.reliant = (agt.indexOf("reliantunix")!=-1);
this.dec = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) ||
(agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) ||
(agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1));
this.sinix = (agt.indexOf("sinix")!=-1);
this.freebsd = (agt.indexOf("freebsd")!=-1);
this.bsd = (agt.indexOf("bsd")!=-1);
this.unix = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux ||
this.sco ||this.unixware || this.mpras || this.reliant ||
this.dec || this.sinix || this.aix || this.linux || this.bsd || this.freebsd);
this.vms = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1));
}
var is;
var isIE3Mac = false;
// this section is designed specifically for IE3 for the Mac
if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) &&
(parseInt(navigator.appVersion)==3))
isIE3Mac = true;
else is = new Is();
END_JSLIBRARY
return $jscript; # Return the JS library code block
}
sub getJSBlocks {
my @jscript = ();
($jscript[0]) = <<'END_JSBLOCK0';
document.write("navigator.appName " + navigator.appName + "<br>");
document.write("navigator.userAgent" + navigator.userAgent + "<br>");
document.write("navigator.appVersion" + navigator.appVersion + "<br>");
END_JSBLOCK0
($jscript[1]) = <<'END_JSBLOCK1';
document.write("<TT>major:" + is.major + "</TT><br>");
document.write("<TT>minor:" + is.minor + "</TT><br>");
END_JSBLOCK1
($jscript[2]) = <<'END_JSBLOCK2';
document.write("nav:" + is.nav + "<br>");
document.write("nav2:" + is.nav2 + "<br>");
document.write("nav3:" + is.nav3 + "<br>");
document.write("nav4:" + is.nav4 + "<br>");
document.write("nav4up:" + is.nav4up + "<br>");
document.write("nav5:" + is.nav5 + "<br>");
document.write("nav5up:" + is.nav5up + "<br>");
document.write("navonly:" + is.navonly + "<br>");
document.write("<P>" + "ie:" + is.ie + "<br>");
document.write("ie3:" + is.ie3 + "<br>");
document.write("ie4:" + is.ie4 + "<br>");
document.write("ie4up:" + is.ie4up + "<br>");
document.write("ie5:" + is.ie5 + "<br>");
document.write("ie5up:" + is.ie5up + "<br>");
document.write("<P>" + "aol:" + is.aol + "<br>");
document.write("aol3:" + is.aol3 + "<br>");
document.write("aol4:" + is.aol4 + "<br>");
document.write("<P>" + "opera:" + is.opera + "<br>");
document.write("<P>" + "webtv:" + is.webtv + "<br>");
END_JSBLOCK2
($jscript[3]) = <<'END_JSBLOCK3';
document.write("js:" + is.js + "<br>");
END_JSBLOCK3
($jscript[4]) = <<'END_JSBLOCK4';
document.write("win:" + is.win + "<br>");
document.write("win16:" + is.win16 + "<br>");
document.write("win31:" + is.win31 + "<br>");
document.write("win32:" + is.win32 + "<br>");
document.write("win95:" + is.win95 + "<br>");
document.write("win98:" + is.win98 + "<br>");
document.write("winnt:" + is.winnt + "<br>");
document.write("<P>" + "os2:" + is.os2 + "<br>");
document.write("<P>" + "mac:" + is.mac + "<br>");
document.write("mac68k:" + is.mac68k + "<br>");
document.write("macppc:" + is.macppc + "<br>");
document.write("<P>" + "unix:" + is.unix + "<br>");
document.write("sun:" + is.sun + "<br>");
document.write("sun4:" + is.sun4 + "<br>");
document.write("sun5:" + is.sun5 + "<br>");
document.write("suni86:" + is.suni86 + "<br>");
document.write("irix:" + is.irix + "<br>");
document.write("irix5:" + is.irix5 + "<br>");
document.write("irix6:" + is.irix6 + "<br>");
document.write("hpux:" + is.hpux + "<br>");
document.write("hpux9:" + is.hpux9 + "<br>");
document.write("hpux10:" + is.hpux10 + "<br>");
document.write("aix:" + is.aix + "<br>");
document.write("aix1:" + is.aix1 + "<br>");
document.write("aix2:" + is.aix2 + "<br>");
document.write("aix3:" + is.aix3 + "<br>");
document.write("aix4:" + is.aix4 + "<br>");
document.write("linux:" + is.linux + "<br>");
document.write("sco:" + is.sco + "<br>");
document.write("unixware:" + is.unixware + "<br>");
document.write("mpras:" + is.mpras + "<br>");
document.write("reliant:" + is.reliant + "<br>");
document.write("dec:" + is.dec + "<br>");
document.write("sinix:" + is.sinix + "<br>");
document.write("bsd:" + is.bsd + "<br>");
document.write("freebsd:" + is.freebsd + "<br>");
document.write("<P>" + "vms:" + is.vms + "<br>");
END_JSBLOCK4
return @jscript;
}
#!/usr/bin/env perl
#jsPacker (July 2005)
#
use strict;
use Pack;
use vars qw($PROGNAME $VERSION
$opt_h $opt_q $opt_v $opt_i $opt_o $opt_e $opt_f $opt_s);
use Getopt::Std;
$PROGNAME = $0;
$VERSION = '1.00b';
my $Description = 'A JavaScript Compressor/Obfuscator';
my $Version = "v$VERSION\[p$Pack::VERSION-pm$Pack::PM_VERSION\]";
# "English" versions of settings
my %ENCODINGS = (0=>'None', 10=>'Decimal', 36=>'Normal', 62=>'Normal', 95=>'High-ascii');
my %SETTINGS = (0=>'No', 1=>'Yes');
exit(0) if &main();
exit(1);
################
# Sub-routines #
################
# Main program
sub main {
# Get command line options
&getopts('hqvfsi:o:e:');
$opt_h ||= 0; # $opt_h shows usage and exits
$opt_q ||= 0; # $opt_q sets quiet mode (no stdout output)
$opt_v ||= 0; # $opt_v shows version and exits
$opt_i ||= ''; # $opt_i is input file. Required!
$opt_o ||= ''; # $opt_o is output file. If not set, use standard output
$opt_e ||= 0; # $opt_e encoding level (0,10,36,62,95)
$opt_f ||= 0; # $opt_f use fast decoding
$opt_s ||= 0; # $opt_x use special characters
# Display help or version if requested
if ($opt_h) {&usage("help")}
if ($opt_v) {&usage("version")}
# Constrain encoding level, fastdecoding and specialcharacters to allowed limits
$opt_e = ($opt_e > 0) ? ($opt_e > 10) ? ($opt_e > 36) ? ($opt_e > 62) ? 95 : 62 : 36 : 10 : 0;
$opt_f = ($opt_f) ? 1 : 0;
$opt_s = ($opt_s) ? 1 : 0;
# Do the job if an input file is specified
if ($opt_i) {
# Read the source script
my $script = &readInputFile($opt_i);
# Pack the source script
my $packedscript = &Pack::pack($script,$opt_e, $opt_f, $opt_s);
# Show what happened (if not in quiet mode)
if (!$opt_q) {showJobDetails($opt_i, $opt_o, $opt_e, $opt_f,$opt_s,\$script,\$packedscript)}
# Output the packed script
if ($opt_o) {&writeOutputFile($opt_o,\$packedscript)} # to output file if specifed
else {print "$packedscript"} # otherwise to STDOUT
}
else { # If no input file is specified, display help
&usage();
}
return(1);
}
######################
sub showJobDetails { #
######################
# Show details of input/output files, settings and compression ratio
my ($inputfile, $outputfile,
$encoding, $fastdecode, $specialchars,
$instringref, $outstringref) = @_;
print "$PROGNAME $Version\n";
print "\tSource file : ";
print "\"$inputfile\"\n";
print (($outputfile) ? ("\tOutput file : \"$outputfile\"\n") : ''); # Print only if output is going to a file
print "\tSettings : encoding=$ENCODINGS{$encoding} fastdecode=$SETTINGS{$fastdecode} specialchars=$SETTINGS{$specialchars}\n";
print "\tCompression : " . &compressionRatio($instringref, $outstringref). "\n\n";
}
#####################
sub readInputFile { #
#####################
# Read content (source script) from input file
my $filename = shift;
open(FH, $filename) || die "Error!!! Problem opening input file \"$filename\"!\n";
my @content = <FH>;
close(FH);
return join('',@content);
}
#######################
sub writeOutputFile { #
#######################
# Write content (packed script) to output file
my ($filename,$refcontent) = @_;
open(FH, ">$filename") || die "Error!!! Problem opening output file \"$filename\"\n";
print(FH $$refcontent);
close(FH);
}
########################
sub compressionRatio { #
########################
# Calculate the ratio of output string to input string
my ($sref1,$sref2) = @_;
my $ratio = (length($$sref2) / (length($$sref1)||1));
$ratio = sprintf "%.2f", $ratio;
return $ratio;
}
#############
sub usage { #
#############
# Inform user about usage, version and exit
my $showusage = 0;
my $showversion = 0;
my $params = shift;
if (defined $params) {
if ($params eq "help") {$showusage = 1;}
elsif ($params eq "version") {$showversion = 1;}
else {$showusage = 1;}
}
else {$showversion = 1;}
if ($showversion) {
print<<EOT;
$PROGNAME $Version
$Description
\tBased on "Packer.js" by Dean Edwards <http://dean.edwards.name/>
\tPorted to Perl by Rob Seiler, ELR Software Pty Ltd <http://www.elr.com.au>
\tCopyright 2005. License <http://creativecommons.org/licenses/LGPL/2.1/>
Use "$PROGNAME -h" for options
EOT
exit(1);
}
if ($showusage) {
print<<EOT;
$PROGNAME $Version
$Description
Usage:
\t$PROGNAME -i inputfile [-o outputfile] [-eX] [-f] [-s] [-qvh]\n
\t-i <inputfile> (eg -i myscript.js)
\t-o <outputfile> (eg -o myscript-p.js)
\t-eN <encoding> [0=None 10=Numeric 62=Normal(alphanumeric) 95=High-ascii]
\t-f <fast decode>
\t-s <special characters>
\t-q quiet mode
\t-v version
\t-h help
Examples:
\t$PROGNAME -i myscript.js
\t$PROGNAME -i myscript.js -o packed.js
\t$PROGNAME -i myscript.js -o packed.js -e10 -f -s
\t$PROGNAME -i myscript.js -e95 -fsq > packed.js
EOT
exit(1);
}
}
#!/bin/sh
DIR=`dirname $0`/..
TARGET0=""
TARGET1=""
TARGET2=""
if [ $# -eq 1 ]; then
TARGET0=$1
else
TARGET0="abvw"
fi
# abvw/js/*
if [ "$TARGET0" = "abvw" ]; then
TARGET1='Limit_Access_Content.js bookmark.js contentsearch.js contentview.js contentview_3d.js contentview_Anket.js contentview_CallApi.js contentview_ContentTypeNone.js contentview_CreateObjects.js contentview_Events.js contentview_General.js contentview_GetData.js contentview_Gomu.js contentview_ImagePreview.js contentview_InitObjects.js contentview_Maker.js contentview_Marking.js contentview_Memo.js contentview_Paint.js contentview_Pen.js contentview_PopupText.js detail.js header.js history.js home.js login.js settings.js share.js stview.js contentview_Streaming.js contentview_Getits.js'
else
TARGET1='contentview.js contentview_3d.js contentview_Anket.js contentview_CallApi.js contentview_ContentTypeNone.js contentview_CreateObjects.js contentview_Events.js contentview_General.js contentview_GetData.js contentview_ImagePreview.js contentview_InitObjects.js contentview_PopupText.js contentview_initDefautValue.js'
fi
# abvw/common/js
if [ "$TARGET0" = "abvw" ]; then
TARGET2='avweb.js common.js i18n.js screenLock.js script.js tab.js textObject.js zoomDetector.js'
else
TARGET2='avweb.js common.js i18n.js script.js textObject.js zoomDetector.js'
fi
OBFUSCATE_EXECUTABLE="$DIR/packer/jsPacker.pl -e10"
for f in $TARGET1
do
ORG=$DIR/$TARGET0/js/$f
TARGET=$DIR/ob/abvw/js/$f
$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done
for f in $TARGET2
do
ORG=$DIR/$TARGET0/common/js/$f
TARGET=$DIR/ob/abvw/common/js/$f
$OBFUSCATE_EXECUTABLE -i $ORG -o $TARGET
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment