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

Commit 0a3a1eb

Browse files
author
chrisisbeef
committed
Getting things rolling
1 parent 9b68e02 commit 0a3a1eb

File tree

1 file changed

+84
-21
lines changed
  • src/main/javascript/org/owasp/esapi

1 file changed

+84
-21
lines changed

src/main/javascript/org/owasp/esapi/Core.js

Lines changed: 84 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,93 @@
1111
* LICENSE before you use, modify, and/or redistribute this software.
1212
*/
1313

14-
@Module(Core)
14+
// @Module(Core)
15+
16+
if (!$) {
17+
/**
18+
* Shortcut to <pre>document.getElementById</pre>
19+
* @param sElementID
20+
* The ID of the element to retrieve
21+
* @return HTMLObject
22+
*/
23+
var $ = function( sElementID ) {
24+
return document.getElementById( sElementID );
25+
};
26+
}
27+
28+
if (!Array.prototype.each) {
29+
/**
30+
* Iterator function for Arrays.
31+
* @param fIterator The iterator function to be executed on each element in the array.
32+
*/
33+
Array.prototype.each = function(fIterator) {
34+
if (typeof fIterator != 'function') {
35+
throw 'Illegal Argument for Array.each';
36+
}
37+
38+
for (var i = 0; i < this.length; i ++) {
39+
fIterator(this[i]);
40+
}
41+
};
42+
}
43+
44+
if (!Array.prototype.contains) {
45+
/**
46+
* Determines whether the passed in object exists in the array.
47+
* @param srch The object to search for
48+
* @return True if the passed in object is found, false otherwise
49+
*/
50+
Array.prototype.contains = function(srch) {
51+
this.each(function(e) {
52+
if (e === srch) {
53+
return true;
54+
}
55+
});
56+
return false;
57+
};
58+
}
59+
60+
$namespace('org.owasp.esapi');
1561

1662
/**
17-
* Creates a new empty namespace if it doesn't already exist.
18-
* @param ns The new namespace to create
19-
* @param sep The seperator for the namespace (default is .)
20-
* @return The namespace created
63+
* DOMUtilities is a collection of helper methods for accessing the DOM. This is primarily for use between ESAPI
64+
* objects, however is accessible to code outside of the ESAPI. While fairly limited, it provides simple shortcut
65+
* methods to common DOM functions.
66+
*
67+
* @author Chris Schmidt ([email protected])
68+
* @since ESAPI 1.0
2169
*/
22-
var $namespace = function( ns, sep ) {
23-
var names = ns.split( sep || '.' ), o = window, i, len;
24-
for ( i = 0, len = names.split; i < len; i ++ ) {
25-
o = o[names[i]] = o[ns[i]] || {};
26-
}
27-
return o;
70+
org.owasp.esapi.DOMUtilities = function() {
71+
2872
};
2973

30-
/**
31-
* Iterator function for Arrays.
32-
* @param fIterator The iterator function to be executed on each element in the array.
33-
*/
34-
Array.prototype.each = function( fIterator ) {
35-
if ( typeof fIterator != 'function' ) { throw 'Illegal Argument for Array.each'; }
74+
org.owasp.esapi.ESAPI = function() {
75+
76+
};
77+
78+
org.owasp.esapi.PreparedString = function() {
79+
/* private */
80+
81+
/**
82+
* This is the placeholder that will be used to mark a parameter
83+
*/
84+
var ch_parameterCharacter = '?';
85+
86+
/**
87+
* The {@link org.owasp.esapi.Codec} that will be used to encode values for parameters passed in
88+
*/
89+
var o_codec = null;
90+
91+
/**
92+
* A working list of parameters
93+
*/
94+
var a_s_parameters = [];
3695

37-
for ( var i=0; i < this.length; i ++ ) {
38-
fIterator(this[i]);
39-
}
40-
};
96+
var a_parts = [];
97+
98+
99+
};
100+
101+
org.owasp.esapi.StringUtilities = function() {
102+
103+
};

0 commit comments

Comments
 (0)