diff --git a/README.md b/README.md
index e081302..ef5652e 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,12 @@ Follow the steps below to get started. For more detailed documentation on this l
- Go to the releases section to get the installation link for both managed and un-managed versions of the ESAPI package.
+* Just latest sources from repo :
+
+
+
+
##Example Code
###Input Validation:
diff --git a/src/classes/ESAPI.cls b/src/classes/ESAPI.cls
index c078627..2cba309 100644
--- a/src/classes/ESAPI.cls
+++ b/src/classes/ESAPI.cls
@@ -1,15 +1,15 @@
/**
* OWASP Enterprise Security API (ESAPI)
- *
+ *
* This file is part of the Open Web Application Security Project (OWASP)
* Enterprise Security API (ESAPI) project. For details, please see
* http://www.owasp.org/index.php/ESAPI.
*
* Copyright (c) 2010 - Salesforce.com
- *
+ *
* The Apex ESAPI implementation is published by Salesforce.com under the New BSD license. You should read and accept the
* LICENSE before you use, modify, and/or redistribute this software.
- *
+ *
* @author Yoel Gluck (securecloud .at. salesforce.com) Salesforce.com
* @created 2010
*/
@@ -18,20 +18,21 @@
* ESAPI locator class is provided to make it easy to gain access to the current ESAPI classes in use.
* For example you can use the validator() function to access the validator methods. (i.e. ESAPI.validator().isValidCreditCard(creditcard, false))
*/
-global with sharing class ESAPI {
+global with sharing class ESAPI {
private static SFDCValidator SFDC_validator = null;
private static SFDCEncoder SFDC_encoder = null;
+ private static SFDCEncoder SFDC_decoder = null;
private static SFDCAccessController SFDC_accessController = null;
-
+
/**
* prevent instantiation of this class
*/
private ESAPI() {
}
-
+
/**
- * @return the current ESAPI SFDCValidator being used to validate data in this application.
+ * @return the current ESAPI SFDCValidator being used to validate data in this application.
*/
global static SFDCValidator validator() {
if (SFDC_validator == null) {
@@ -41,17 +42,27 @@ global with sharing class ESAPI {
}
/**
- * @return the current SFDCEncoder object. This gives the basic encoding functionality as those availabel in VisualForce (HTMLENCODE, JSENCODE, JSINHTMLENCODE and URLENCODE)
+ * @return the current SFDCEncoder object. This gives the basic encoding functionality as those availabel in VisualForce (HTMLENCODE, JSENCODE, JSINHTMLENCODE and URLENCODE)
*/
global static SFDCEncoder encoder() {
if (SFDC_encoder == null) {
SFDC_encoder = new SFDCEncoder();
- }
+ }
return SFDC_encoder;
}
-
+
+ /**
+ * @return the current SFDCDecoder object. This gives the basic decoding functionality
+ */
+ global static SFDCDecoder decoder() {
+ if (SFDC_decoder == null) {
+ SFDC_decoder = new SFDCDecoder();
+ }
+ return SFDC_decoder;
+ }
+
/**
- * @return the current ESAPI SFDCAccessController object being used to maintain the access control rules for this application.
+ * @return the current ESAPI SFDCAccessController object being used to maintain the access control rules for this application.
*/
global static SFDCAccessController accessController() {
if (SFDC_accessController == null) {
diff --git a/src/classes/SFDCDecoder.cls b/src/classes/SFDCDecoder.cls
new file mode 100644
index 0000000..827ddc9
--- /dev/null
+++ b/src/classes/SFDCDecoder.cls
@@ -0,0 +1,42 @@
+/**
+ * OWASP Enterprise Security API (ESAPI)
+ *
+ * This file is part of the Open Web Application Security Project (OWASP)
+ * Enterprise Security API (ESAPI) project. For details, please see
+ * http://www.owasp.org/index.php/ESAPI.
+ *
+ * Copyright (c) 2010 - Salesforce.com
+ *
+ * The Apex ESAPI implementation is published by Salesforce.com under the New BSD license. You should read and accept the
+ * LICENSE before you use, modify, and/or redistribute this software.
+ *
+ * @author Sébastien Colladon (scolladon .at. salesforce.com) Salesforce.com
+ * @created 2016
+ */
+
+/**
+ * This class is a basic decoder.
+ */
+global with sharing class SFDCDecoder {
+
+
+ /**
+ * Note : This function always decodes a base64 url encoded string
+ *
+ * Example:
+ *
+ * //htmlstr is going to be converted from url to blob + * htmlstr = ESAPI.decoder().SFDC_BASE64_URLDECODE(base64urlencodedText); + *+ */ + global Blob SFDC_BASE64_URLDECODE(final String input){ + if(String.isBlank(input)) { + return null; + } + + return EncodingUtil.base64Decode(input.replace('-', '+') + .replace('_', '/') + .rightPad(math.mod(input.length() + (math.mod(4 - input.length(), 4)), 4)) + .replace(' ','=')); + } +} \ No newline at end of file diff --git a/src/classes/SFDCDecoder.cls-meta.xml b/src/classes/SFDCDecoder.cls-meta.xml new file mode 100644 index 0000000..38aa015 --- /dev/null +++ b/src/classes/SFDCDecoder.cls-meta.xml @@ -0,0 +1,5 @@ + +