Escapes a string as a URI query parameter (same as a strict query, but also escaping & and =)
@param queryParam the parameter to escape
@param strict whether or not to do strict escaping
@return the escaped string
8221
public static String escapeQueryParam(final String queryParam, final boolean strict) {
        return (strict ? STRICT_ESCAPER : ESCAPER).escapeQueryParam(queryParam);
    }
330165
def parse_uri_query_params(query)
      query.to_s.split('&'.freeze).reduce({}) do |h, p|
        k, v = p.split('='.freeze, 2)
        v = URI::Generic::DEFAULT_PARSER.unescape(v) if v
        h[k.to_sym] = v || true
        h
      end
    end
546121
public static String escape(final String url, final boolean strict) {
        return (strict ? STRICT_ESCAPER : ESCAPER).escape(url);
    }
1137005
private static String queryString( final Map<String, List<String>> params ) {
        final StringBuilder builder = new StringBuilder();
        if (params != null && params.size() > 0) {
            for (final Iterator<String> it = params.keySet().iterator(); it.hasNext(); ) {
                final String key = it.next();
                final List<String> values = params.get(key);
                for (final String value : values) {
                    try {
                        builder.append(key + "=" + URLEncoder.encode(value, "UTF-8") + "&");
                    } catch (final UnsupportedEncodingException e) {
                        builder.append(key + "=" + value + "&");
                    }
                }
            }
            return builder.length() > 0 ? "?" + builder.substring(0, builder.length() - 1) : "";
        }
        return "";
    }
106302
public static Map<String, String> parseQuery(String query) {
		Map<String, String> result = new LinkedHashMap<String, String>();
		
		if (query != null) {
			for (String keyValue: query.split("&")) {
				String[] pair = keyValue.split("=");
				result.put(StringUtils.urlDecode(pair[0]), StringUtils.urlDecode(pair[1]));
			}
		}
		
		return result;
	}
284180
public URI forURL(URI uri) {
        QueryStringEncoder encoder = new QueryStringEncoder(uri.toString());
        for (Map.Entry<String, Object> e : params.entrySet()) {
            encoder.addParam(e.getKey(), String.valueOf(e.getValue()));
        }
        try {
            return encoder.toUri();
        } catch (URISyntaxException e) {
            throw new IllegalArgumentException("Cannot construct a query string from the given params. " +
                    "An invalid parameter was used.");
        }
    }
471738
private static String escapeSQLParam(final String param) {
		int stringLength = param.length();
		StringBuilder buf = new StringBuilder((int) (stringLength * 1.1));
		for (int i = 0; i < stringLength; ++i) {
			char c = param.charAt(i);
			switch (c) {
			case 0: /* Must be escaped for 'mysql' */
				buf.append('\\');
				buf.append('0');
				break;
			case '\n': /* Must be escaped for logs */
				buf.append('\\');
				buf.append('n');
				break;
			case '\r':
				buf.append('\\');
				buf.append('r');
				break;
			case '\\':
				buf.append('\\');
				buf.append('\\');
				break;
			case '\'':
				buf.append('\\');
				buf.append('\'');
				break;
			case '"': /* Better safe than sorry */
				buf.append('\\');
				buf.append('"');
				break;
			case '\032': /* This gives problems on Win32 */
				buf.append('\\');
				buf.append('Z');
				break;
			default:
				buf.append(c);
			}
		}
		return buf.toString();
	}
1148080
public static URI urlToUri( URL url ) throws URISyntaxException {

		URI uri;
		try {
			// Possible failing step.
			uri = url.toURI();

		} catch( Exception e ) {
			// URL did not comply with RFC 2396 => illegal non-escaped characters.
			try {
				uri = new URI(
						url.getProtocol(),
						url.getUserInfo(),
						url.getHost(),
						url.getPort(),
						url.getPath(),
						url.getQuery(),
						url.getRef());

			} catch( Exception e1 ) {
				throw new URISyntaxException( String.valueOf( url ), "Broken URL." );
			}
		}

		uri = uri.normalize();
		return uri;
	}
933070
function appendQueryString(url, params){
        var key;
        url = url || '';
        if(params){
            if(url.indexOf('?') === -1){
                url += '?';
            }
            if(typeof params === 'string'){
                url += params;
            } else if (typeof params === 'object'){
                for(key in params){
                    if(!/[?&]$/.test(url)){
                        url += '&';
                    }
                    url += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
                }
            }
        }

        return url;
    }
28633
public OpenStackRequest<R> queryString(String queryString) {
        if (queryString != null) {
            String[] params = queryString.split("&");
            for (String param : params) {
                String[] s = param.split("=");
                if (s[0] != null && s[1] != null) {
                    queryParam(s[0], s[1]);
                }
            }
        }
        return this;
    }
930301
public static Map<String,String> getQueryParams(String s) throws MalformedURLException {
        Map<String,String> params = new HashMap<String, String>();

        for (String kv : s.split("&")) {
            String[] parts = kv.split("=");
            if (parts.length != 2) {
                throw new MalformedURLException();
            }
            try {
                String k = URLDecoder.decode(parts[0], "UTF-8");
                String v = URLDecoder.decode(parts[1], "UTF-8");
                params.put(k, v);
            } catch (UnsupportedEncodingException ex) {
                throw new MalformedURLException(ex.getMessage());
            }
        }
        return params;
    }
637846
public static String encodeQuery(String query) throws NullPointerException {
		return new String(encode(query, UriComponentEncoderBitSets.allowed_query));
	}
889917
function strictQueryParams(options) {

    var opts = options || {};
    assert.optionalObject(opts, 'options');
    assert.optionalString(opts.message, 'options.message');

    function _strictQueryParams(req, res, next) {

        var keyValQParams = !/(\&(?!(\w+=\w+)))/.test(req.url);

        if (!keyValQParams) {
            var msg = opts.message ? opts.message :
                'Url query params does not meet strict format';
            return next(new BadRequestError(msg));
        }

        return next();
    }

    return (_strictQueryParams);
}
603465
public static String queryEncode(String query, Charset charset) {
    return encodeReserved(query, FragmentType.QUERY, charset);

    /* spaces will be encoded as 'plus' symbols here, we want them pct-encoded */
    // return encoded.replaceAll("\\+", "%20");
  }
362436
public static String escapePath(final String path, final boolean strict) {
        return (strict ? STRICT_ESCAPER : ESCAPER).escapePath(path);
    }
717477
public static String escapeEntities(String str, boolean strict) {
        StringBuilder buffer;
        char ch;
        String msg;
        String entity;

        buffer = null;
        for (int i = 0; i < str.length(); i++) {
            ch = str.charAt(i);
            switch (ch) {
                case '\t':
                case '\n':
                case '\r':
                    entity = null;
                    break;
                case '<' :
                    entity = "&lt;";
                    break;
                case '>' :
                    entity = "&gt;";
                    break;
                case '\'' :
                    entity = "&apos;";
                    break;
                case '\"' :
                    entity = "&quot;";
                    break;
                case '&' :
                    entity = "&amp;";
                    break;
                default :
                    if (ch < 32) {
                        msg = "illegal character code " + (int) ch;
                        if (strict) {
                            throw new IllegalArgumentException(msg);
                        }
                        entity = "[" + msg + "]";
                    } else if (ch < 256) {
                        entity = null;
                    } else {
                        entity = "&#" + (int) ch + ";";
                    }
                    break;
            }
            if (buffer == null) {
                if (entity != null) {
                    buffer = new StringBuilder(str.length() + 5);
                    buffer.append(str.substring(0, i));
                    buffer.append(entity);
                }
            } else {
                if (entity == null) {
                    buffer.append(ch);
                } else {
                    buffer.append(entity);
                }
            }
        }
        return buffer == null ? str : buffer.toString();
    }
401679
public static String encodeParameter(Object source) {

		Assert.notNull(source, "Request parameter value must not be null!");

		try {
			return UriUtils.encodeQueryParam(source.toString(), ENCODING);
		} catch (Throwable e) {
			throw new IllegalStateException(e);
		}
	}