java.lang.Object
com.aoindustries.aoserv.client.util.ApacheEscape

public final class ApacheEscape extends Object
Escapes arbitrary values for use in Apache directives.
Author:
AO Industries, Inc.
  • Field Details

  • Method Details

    • escape

      public static String escape(String dollarVariable, String value)
      Escapes arbitrary text to be used in an Apache directive. Adds double quotes as-needed. Please note that '$' is also escaped when found in form ${variable}, so this might not be appropriate for ${variable} substitutions.

      Please note, the dollar escaping relies on Apache being configured with Define <dollarVariable> $, as it is performed with a ${dollarVariable} hack.

      See Also:
    • escape

      public static String escape(String dollarVariable, String value, boolean allowVariables)
      Escapes arbitrary text to be used in an Apache directive. Adds double quotes as-needed. Optionally allowing '$' unescaped.

      Please note, the dollar escaping relies on Apache being configured with Define $ $, as it is performed with a ${$} hack. This is set in the aoserv-httpd-config package, in core.inc.

      I am unable to find clear documentation on the full set of rules for escaping Apache directives. I have experimented with various values and techniques to achieve this implementation. It seems there is no useful way to encode completely arbitrary values into directives. Thus, this set of rules may not be optimal (may perform more escaping than necessary) or, even worse, could be incomplete.

      Returns:
      the escaped string or the original string when no escaping required
      See Also: