Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit 44b207f

Browse files
author
chrisisbeef
committed
Release 0.1.3
1 parent a94ebf8 commit 44b207f

File tree

199 files changed

+21473
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+21473
-6
lines changed

dist/build-functions.php

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
<?php
2+
/*
3+
* OWASP Enterprise Security API (ESAPI)
4+
*
5+
* This file is part of the Open Web Application Security Project (OWASP)
6+
* Enterprise Security API (ESAPI) project. For details, please see
7+
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
8+
*
9+
* Copyright (c) 2008 - The OWASP Foundation
10+
*
11+
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
12+
* LICENSE before you use, modify, and/or redistribute this software.
13+
*/
14+
15+
/**
16+
* Delete a file, or a folder and its contents (recursive algorithm)
17+
*
18+
* @author Aidan Lister <[email protected]>
19+
* @version 1.0.3
20+
* @link http://aidanlister.com/repos/v/function.rmdirr.php
21+
* @param string $dirname Directory to delete
22+
* @return bool Returns TRUE on success, FALSE on failure
23+
*/
24+
function rmdirr($dirname)
25+
{
26+
// Sanity check
27+
if (!file_exists($dirname)) {
28+
return false;
29+
}
30+
31+
// Simple delete for a file
32+
if (is_file($dirname) || is_link($dirname)) {
33+
return unlink($dirname);
34+
}
35+
36+
// Loop through the folder
37+
$dir = dir($dirname);
38+
while (false !== $entry = $dir->read()) {
39+
// Skip pointers
40+
if ($entry == '.' || $entry == '..' || $entry == '.svn' ) {
41+
continue;
42+
}
43+
44+
// Recurse
45+
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
46+
}
47+
48+
// Clean up
49+
$dir->close();
50+
return;// rmdir($dirname);
51+
}
52+
53+
/**
54+
* Compress Javascript/CSS using the YUI Compressor
55+
*
56+
* You must set $jarFile and $tempDir before calling the minify functions.
57+
* Also, depending on your shell's environment, you may need to specify
58+
* the full path to java in $javaExecutable or use putenv() to setup the
59+
* Java environment.
60+
*
61+
* <code>
62+
* Minify_YUICompressor::$jarFile = '/path/to/yuicompressor-2.3.5.jar';
63+
* Minify_YUICompressor::$tempDir = '/tmp';
64+
* $code = Minify_YUICompressor::minifyJs(
65+
* $code
66+
* ,array('nomunge' => true, 'line-break' => 1000)
67+
* );
68+
* </code>
69+
*
70+
* @todo unit tests, $options docs
71+
*
72+
* @package Minify
73+
* @author Stephen Clay <[email protected]>
74+
*/
75+
class Minify_YUICompressor {
76+
77+
/**
78+
* Filepath of the YUI Compressor jar file. This must be set before
79+
* calling minifyJs() or minifyCss().
80+
*
81+
* @var string
82+
*/
83+
public static $jarFile = null;
84+
85+
/**
86+
* Writable temp directory. This must be set before calling minifyJs()
87+
* or minifyCss().
88+
*
89+
* @var string
90+
*/
91+
public static $tempDir = null;
92+
93+
/**
94+
* Filepath of "java" executable (may be needed if not in shell's PATH)
95+
*
96+
* @var string
97+
*/
98+
public static $javaExecutable = 'java';
99+
100+
/**
101+
* Minify a Javascript string
102+
*
103+
* @param string $js
104+
*
105+
* @param array $options (verbose is ignored)
106+
*
107+
* @see http://www.julienlecomte.net/yuicompressor/README
108+
*
109+
* @return string
110+
*/
111+
public static function minifyJs($js, $options = array())
112+
{
113+
return self::_minify('js', $js, $options);
114+
}
115+
116+
/**
117+
* Minify a CSS string
118+
*
119+
* @param string $css
120+
*
121+
* @param array $options (verbose is ignored)
122+
*
123+
* @see http://www.julienlecomte.net/yuicompressor/README
124+
*
125+
* @return string
126+
*/
127+
public static function minifyCss($css, $options = array())
128+
{
129+
return self::_minify('css', $css, $options);
130+
}
131+
132+
private static function _minify($type, $content, $options)
133+
{
134+
self::_prepare();
135+
if (! ($tmpFile = tempnam(self::$tempDir, 'yuic_'))) {
136+
throw new Exception('Minify_YUICompressor : could not create temp file.');
137+
}
138+
file_put_contents($tmpFile, $content);
139+
exec(self::_getCmd($options, $type, $tmpFile), $output);
140+
unlink($tmpFile);
141+
return implode("\n", $output);
142+
}
143+
144+
private static function _getCmd($userOptions, $type, $tmpFile)
145+
{
146+
$o = array_merge(
147+
array(
148+
'charset' => ''
149+
,'line-break' => 5000
150+
,'type' => $type
151+
,'nomunge' => false
152+
,'preserve-semi' => false
153+
,'disable-optimizations' => false
154+
)
155+
,$userOptions
156+
);
157+
$cmd = self::$javaExecutable . ' -jar ' . escapeshellarg(self::$jarFile)
158+
. " --type {$type}"
159+
. (preg_match('/^[a-zA-Z\\-]+$/', $o['charset'])
160+
? " --charset {$o['charset']}"
161+
: '')
162+
. (is_numeric($o['line-break']) && $o['line-break'] >= 0
163+
? ' --line-break ' . (int)$o['line-break']
164+
: '');
165+
if ($type === 'js') {
166+
foreach (array('nomunge', 'preserve-semi', 'disable-optimizations') as $opt) {
167+
$cmd .= $o[$opt]
168+
? " --{$opt}"
169+
: '';
170+
}
171+
}
172+
return $cmd . ' ' . escapeshellarg($tmpFile);
173+
}
174+
175+
private static function _prepare()
176+
{
177+
if (! is_file(self::$jarFile)
178+
|| ! is_dir(self::$tempDir)
179+
|| ! is_writable(self::$tempDir)
180+
) {
181+
throw new Exception('Minify_YUICompressor : $jarFile and $tempDir must be set.');
182+
}
183+
}
184+
}
185+
186+
function get_files($root_dir, $allow_extensions = array( 'js' ), $ignore_files = array( ), $ignore_regex = '/^_/', $ignore_dirs = array(".","..",".svn"), $all_data=array() )
187+
{
188+
// run through content of root directory
189+
$dir_content = scandir($root_dir);
190+
foreach($dir_content as $key => $content)
191+
{
192+
$path = $root_dir.'/'.$content;
193+
if(is_file($path) && is_readable($path))
194+
{
195+
// skip ignored files
196+
if(!in_array($content, $ignore_files))
197+
{
198+
if (preg_match($ignore_regex,$content) == 0)
199+
{
200+
$content_chunks = explode(".",$content);
201+
$ext = $content_chunks[count($content_chunks) - 1];
202+
// only include files with desired extensions
203+
if ( ( is_array( $allow_extensions ) && in_array($ext, $allow_extensions) ) || ( is_string( $allow_extensions ) && $allow_extensions == '*' ) )
204+
{
205+
// save file name with path
206+
$all_data[] = $path;
207+
}
208+
}
209+
}
210+
}
211+
// if content is a directory and readable, add path and name
212+
elseif(is_dir($path) && is_readable($path))
213+
{
214+
// skip any ignored dirs
215+
if(!in_array($content, $ignore_dirs))
216+
{
217+
// recursive callback to open new directory
218+
$all_data = get_files($path, $allow_extensions, $ignore_files, $ignore_regex, $ignore_dirs, $all_data);
219+
}
220+
}
221+
} // end foreach
222+
return $all_data;
223+
} // end get_files()
224+
225+
function microtime_float() {
226+
list($usec,$sec) = explode(" ",microtime());
227+
return ((float)$usec + (float)$sec);
228+
}
229+
230+
function copydir( $src, $dst, $allow_extensions = array( 'js' ), $ignore_files = array( ), $ignore_regex = '/^_/', $ignore_dirs = array(".","..",".svn") ) {
231+
$filelist = get_files($src, $allow_extensions, $ignore_files, $ignore_regex, $ignore_dirs);
232+
foreach($filelist as $i=>$file) {
233+
$dir_name = substr( $file, 0, strrpos( $file, '/' ) );
234+
$dir_name = substr( $dir_name, strlen($src)+1 );
235+
if ( !is_dir($dst.$dir_name) ) {
236+
echo("- Creating Directory: $dst$dir_name\n");
237+
mkdir($dst.$dir_name);
238+
}
239+
240+
$dst_file = substr( $file, strlen( $src )+1 );
241+
echo("- $file (".filesize($file)." bytes) => $dst$dst_file");
242+
copy( $file, $dst.$dst_file );
243+
usleep(5000);
244+
if ( filesize($file) == filesize($dst.$dst_file) )
245+
echo("\t[OK]\n");
246+
else
247+
echo("\t[ERROR]\n");
248+
}
249+
}
250+
?>

dist/build-properties.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/*
3+
* OWASP Enterprise Security API (ESAPI)
4+
*
5+
* This file is part of the Open Web Application Security Project (OWASP)
6+
* Enterprise Security API (ESAPI) project. For details, please see
7+
* <a href="http://www.owasp.org/index.php/ESAPI">http://www.owasp.org/index.php/ESAPI</a>.
8+
*
9+
* Copyright (c) 2008 - The OWASP Foundation
10+
*
11+
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
12+
* LICENSE before you use, modify, and/or redistribute this software.
13+
*/
14+
15+
$DOCUMENTATION_DIR = "documentation";
16+
$SOURCE_DIR = "src/main/javascript";
17+
$RESOURCES_DIR = "src/main/resources";
18+
$LIB_DIR = "lib";
19+
$OUTPUT_DIR = "dist/";
20+
$OUTPUT_RESOURCES = "resources/";
21+
$OUTPUT_DOCUMENTATION = "docs/";
22+
$OUTPUT_LIBS = "lib/";
23+
$OUTPUT_FILE = "esapi.js";
24+
$OUTPUT_FILE_COMPRESSED = "esapi-compressed.js";
25+
$OUTPUT_SRC = "src/";
26+
27+
$JDK_HOME = "/home/cschmidt/jdk1.6.0_14/";
28+
$YUI_COMPRESSOR_JAR = "lib/yuicompressor-2.4.2.jar";
29+
$TMP_DIR = "tmp/";
30+
31+
$LICENSE_TEXT =
32+
"/*
33+
* OWASP Enterprise Security API (ESAPI)
34+
*
35+
* This file is part of the Open Web Application Security Project (OWASP)
36+
* Enterprise Security API (ESAPI) project. For details, please see
37+
* <a href=\"http://www.owasp.org/index.php/ESAPI\">http://www.owasp.org/index.php/ESAPI</a>.
38+
*
39+
* Copyright (c) 2008 - The OWASP Foundation
40+
*
41+
* The ESAPI is published by OWASP under the BSD license. You should read and accept the
42+
* LICENSE before you use, modify, and/or redistribute this software.
43+
*/\n";
44+
?>

build.log renamed to dist/build.log

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Building Uncompressed File: dist/esapi.js
1+
Cleaning up Distribution DirectoryBuilding Uncompressed File: dist/esapi.js
22
- Reading src/main/javascript/core.js
33
- Reading src/main/javascript/org/owasp/esapi/Encoder.js
44
- Reading src/main/javascript/org/owasp/esapi/EncoderConstants.js
@@ -21,7 +21,9 @@ Building Uncompressed File: dist/esapi.js
2121
- Reading src/main/javascript/org/owasp/esapi/codecs/UTF8.js
2222
- Reading src/main/javascript/org/owasp/esapi/i18n/ArrayResourceBundle.js
2323
- Reading src/main/javascript/org/owasp/esapi/i18n/Locale.js
24+
- Reading src/main/javascript/org/owasp/esapi/i18n/ObjectResourceBundle.js
2425
- Reading src/main/javascript/org/owasp/esapi/i18n/ResourceBundle.js
26+
- Reading src/main/javascript/org/owasp/esapi/net/Cookie.js
2527
- Reading src/main/javascript/org/owasp/esapi/reference/encoding/DefaultEncoder.js
2628
- Reading src/main/javascript/org/owasp/esapi/reference/logging/Log4JSLogFactory.js
2729
- Reading src/main/javascript/org/owasp/esapi/reference/validation/BaseValidationRule.js
@@ -32,23 +34,27 @@ Building Uncompressed File: dist/esapi.js
3234
- Reading src/main/javascript/org/owasp/esapi/reference/validation/NumberValidationRule.js
3335
- Reading src/main/javascript/org/owasp/esapi/reference/validation/StringValidationRule.js
3436
- Reading src/main/javascript/org/owasp/esapi/reference/validation/ValidationException.js
35-
Finished building dist/esapi.js (107480 bytes): Took 0.0145349502563s
37+
Finished building dist/esapi.js (112526 bytes): Took 0.0149080753326s
3638

3739
Building Compressed File: dist/esapi-compressed.js
38-
Finished building dist/esapi-compressed.js (52134 bytes): Took 1.20844578743s
40+
Finished building dist/esapi-compressed.js (52325 bytes): Took 1.20039391518s
3941

4042
Copying Resources to dist/resources/
41-
- src/main/resources/Base.esapi.properties.js (2044 bytes) => dist/resources/Base.esapi.properties.js [OK]
43+
- src/main/resources/Base.esapi.properties.js (2546 bytes) => dist/resources/Base.esapi.properties.js [OK]
44+
- src/main/resources/i18n/ESAPI_Standard_en_US.properties.js (4769 bytes) => dist/resources/i18n/ESAPI_Standard_en_US.properties.js [OK]
4245

4346
Copying Documentation to dist/docs/
44-
- documentation/README (2587 bytes) => dist/docs/README [OK]
47+
- documentation/CHANGELOG (1596 bytes) => dist/docs/CHANGELOG [OK]
48+
- documentation/README (2773 bytes) => dist/docs/README [OK]
4549

4650
Copying Libraries to dist/lib/
4751
- lib/log4js-lib.js (34303 bytes) => dist/lib/log4js-lib.js [OK]
4852
- lib/log4js.js (68555 bytes) => dist/lib/log4js.js [OK]
4953

54+
Copying Build Files and LICENSE
55+
5056
Cleaning Up
5157

52-
Build complete took 1.22696089745s
58+
Build complete took 1.2509329319s
5359

5460

0 commit comments

Comments
 (0)