// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
// public class ValidationStrategy<O> {
// 
//     public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
//     public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
//     public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
//     public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
// 
//     public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
//     public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
//     public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
//     public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
// 
//     private final Canonicalizer<O> _canonicalizer;
//     private final Validator<O> _validator;
//     private final Sanitizer<O> _sanitizer;
// 
//     public ValidationStrategy(Canonicalizer<O> canonicalizer, Validator<O> validator, Sanitizer<O> sanitizer) {
//         _canonicalizer = canonicalizer;
//         _validator = validator;
//         _sanitizer = sanitizer;
//     }
// 
//     public final Canonicalizer<O> getCanonicalizer() {
//         return _canonicalizer;
//     }
// 
//     public final Validator<O> getValidator() {
//         return _validator;
//     }
// 
//     public final Sanitizer<O> getSanitizer() {
//         return _sanitizer;
//     }
// 
//     public final O validate(O content) {
//         O canonicalized = null;
//         try {
//             canonicalized = _canonicalizer != null ? _canonicalizer.execute(content) : content;
//         } catch (Exception e) {
//             throw new ValidatorException("", "Failed to canonicalize content.");
//         }
//         if (_validator != null && !_validator.execute(canonicalized)) {
//             throw StringUtils.isBlank(_validator.getErrorMessage()) ? new ValidatorException(canonicalized.toString()) :
//                 new ValidatorException(canonicalized.toString(), _validator.getErrorMessage());
//         }
//         try {
//             return _sanitizer != null ? _sanitizer.execute(canonicalized) : canonicalized;
//         } catch (Exception e) {
//             throw new ValidatorException("", "Failed to sanitize content.");
//         }
//     }
// }


import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import com.switchfly.inputvalidation.ValidationStrategy;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
        String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);

        try {
            return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    public static List<NameValuePair> parse(URI uri) {
        final String query = uri.getRawQuery();
        return parse(query);
    }

    public static List<NameValuePair> parse(String queryString) {
        List<NameValuePair> result = Collections.emptyList();
        if (queryString != null && queryString.length() > 0) {
            result = new ArrayList<NameValuePair>();
            parse(result, new Scanner(queryString));
        }
        return result;
    }

    private static void parse(List<NameValuePair> parameters, Scanner scanner) {
        scanner.useDelimiter(PARAMETER_SEPARATOR);
        while (scanner.hasNext()) {
            String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
            if (nameValue.length == 0 || nameValue.length > 2) {
                throw new IllegalArgumentException("bad parameter");
            }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
// public class ValidationStrategy<O> {
// 
//     public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
//     public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
//     public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
//     public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
// 
//     public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
//     public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
//     public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
//     public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
// 
//     private final Canonicalizer<O> _canonicalizer;
//     private final Validator<O> _validator;
//     private final Sanitizer<O> _sanitizer;
// 
//     public ValidationStrategy(Canonicalizer<O> canonicalizer, Validator<O> validator, Sanitizer<O> sanitizer) {
//         _canonicalizer = canonicalizer;
//         _validator = validator;
//         _sanitizer = sanitizer;
//     }
// 
//     public final Canonicalizer<O> getCanonicalizer() {
//         return _canonicalizer;
//     }
// 
//     public final Validator<O> getValidator() {
//         return _validator;
//     }
// 
//     public final Sanitizer<O> getSanitizer() {
//         return _sanitizer;
//     }
// 
//     public final O validate(O content) {
//         O canonicalized = null;
//         try {
//             canonicalized = _canonicalizer != null ? _canonicalizer.execute(content) : content;
//         } catch (Exception e) {
//             throw new ValidatorException("", "Failed to canonicalize content.");
//         }
//         if (_validator != null && !_validator.execute(canonicalized)) {
//             throw StringUtils.isBlank(_validator.getErrorMessage()) ? new ValidatorException(canonicalized.toString()) :
//                 new ValidatorException(canonicalized.toString(), _validator.getErrorMessage());
//         }
//         try {
//             return _sanitizer != null ? _sanitizer.execute(canonicalized) : canonicalized;
//         } catch (Exception e) {
//             throw new ValidatorException("", "Failed to sanitize content.");
//         }
//     }
// }


// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import com.switchfly.inputvalidation.ValidationStrategy;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;

        String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);

        try {
            return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
        } catch (URISyntaxException e) {
            throw new RuntimeException(e);
        }
    }

    public static List<NameValuePair> parse(URI uri) {
        final String query = uri.getRawQuery();
        return parse(query);
    }

    public static List<NameValuePair> parse(String queryString) {
        List<NameValuePair> result = Collections.emptyList();
        if (queryString != null && queryString.length() > 0) {
            result = new ArrayList<NameValuePair>();
            parse(result, new Scanner(queryString));
        }
        return result;
    }

    private static void parse(List<NameValuePair> parameters, Scanner scanner) {
        scanner.useDelimiter(PARAMETER_SEPARATOR);
        while (scanner.hasNext()) {
            String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
            if (nameValue.length == 0 || nameValue.length > 2) {
                throw new IllegalArgumentException("bad parameter");
            }
            String name = ValidationStrategy.PROPERTY_NAME.cleanStrategy().validate(nameValue[0]);