]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Modified command line and config file parser to allow
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Mon, 22 Oct 2007 19:19:21 +0000 (19:19 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Mon, 22 Oct 2007 19:19:21 +0000 (19:19 +0000)
quoted strings using single quotes ('') (Alon Bar-Lev).

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@2414 e7ae566f-a301-0410-adde-c780ea21d3b5

openvpn.8
options.c

index aa48e70a3cbe1923e97a9ac92921c1dbe34a02f5..287e2e18ee76a5b2d00863ba59c8ad247815dc76 100644 (file)
--- a/openvpn.8
+++ b/openvpn.8
@@ -380,13 +380,14 @@ can be removed, and the command can be given as
 Note that
 configuration files can be nested to a reasonable depth.
 
-Double quotation characters ("") can be used
-to enclose single parameters containing whitespace,
+Double quotation or single quotation characters ("", '')
+can be used to enclose single parameters containing whitespace,
 and "#" or ";" characters in the first column
 can be used to denote comments.
 
 Note that OpenVPN 2.0 and higher performs backslash-based shell
-escaping, so the following mappings should be observed:
+escaping for characters not in single quotations,
+so the following mappings should be observed:
 
 .RS
 .ft 3
index f2310fca866bb07535cfddf245811834cd67dc64..5cc7f234cec53fda855a8b3a4df6efa7a66e007e 100644 (file)
--- a/options.c
+++ b/options.c
@@ -2577,6 +2577,7 @@ parse_line (const char *line,
   const int STATE_READING_QUOTED_PARM = 1;
   const int STATE_READING_UNQUOTED_PARM = 2;
   const int STATE_DONE = 3;
+  const int STATE_READING_SQUOTED_PARM = 4;
 
   const char *error_prefix = "";
 
@@ -2599,7 +2600,7 @@ parse_line (const char *line,
       in = *c;
       out = 0;
 
-      if (!backslash && in == '\\')
+      if (!backslash && in == '\\' && state != STATE_READING_SQUOTED_PARM)
        {
          backslash = true;
        }
@@ -2613,6 +2614,8 @@ parse_line (const char *line,
                    break;
                  if (!backslash && in == '\"')
                    state = STATE_READING_QUOTED_PARM;
+                 else if (!backslash && in == '\'')
+                   state = STATE_READING_SQUOTED_PARM;
                  else
                    {
                      out = in;
@@ -2634,6 +2637,13 @@ parse_line (const char *line,
              else
                out = in;
            }
+         else if (state == STATE_READING_SQUOTED_PARM)
+           {
+             if (in == '\'')
+               state = STATE_DONE;
+             else
+               out = in;
+           }
          if (state == STATE_DONE)
            {
              /* ASSERT (parm_len > 0); */
@@ -2681,6 +2691,11 @@ parse_line (const char *line,
       msg (msglevel, "%sOptions error: No closing quotation (\") in %s:%d", error_prefix, file, line_num);
       return 0;
     }
+  if (state == STATE_READING_SQUOTED_PARM)
+    {
+      msg (msglevel, "%sOptions error: No closing single quotation (\') in %s:%d", error_prefix, file, line_num);
+      return 0;
+    }
   if (state != STATE_INITIAL)
     {
       msg (msglevel, "%sOptions error: Residual parse state (%d) in %s:%d", error_prefix, state, file, line_num);