summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJiří Klimeš <blueowl@centrum.cz>2016-11-10 18:13:36 +0100
committerJiří Klimeš <blueowl@centrum.cz>2016-11-10 20:56:44 +0100
commit79643ce28a197585299abc5c2cd1407758fd0067 (patch)
tree27c699a0320b081678735fa8c0081d7b533243d8 /contrib
parentc4ed2483b2ce512c92949dc9b87a90e3bce447ac (diff)
downloadNetworkManager-79643ce28a197585299abc5c2cd1407758fd0067.tar.gz
nm-import-openvpn: parse quoted string as a single word
It is necessary, for example, for this to work: verify-x509-name "C=US, L=Cambridge, CN=GNOME, emailAddress=networkmanager-list@gnome.org" subject
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/scripts/nm-import-openvpn25
1 files changed, 21 insertions, 4 deletions
diff --git a/contrib/scripts/nm-import-openvpn b/contrib/scripts/nm-import-openvpn
index c8af9d996e..7b8d2aa7e0 100755
--- a/contrib/scripts/nm-import-openvpn
+++ b/contrib/scripts/nm-import-openvpn
@@ -332,10 +332,27 @@ vpn2nm = {
-- Read and convert the config into the global g_vpn_data --
-----------------------------------------------------------
function read_and_convert(in_file)
- local function line_split(str)
- t={}; i = 1
- for str in str:gmatch("%S+") do
- t[i] = str
+ local function line_split(line)
+ local t={}
+ local i, idx = 1, 1
+ local delim = "\""
+ while true do
+ local a,b = line:find("%S+", idx)
+ if not a then break end
+
+ local str = line:sub(a,b)
+ local quote = nil
+ if str:sub(1,1) == delim and str:sub(#str,#str) ~= delim then
+ quote = (line.." "):find(delim.."%s", b + 1)
+ end
+
+ if quote then
+ t[i] = line:sub(a, quote)
+ idx = quote + 1
+ else
+ t[i] = str
+ idx = b + 1
+ end
i = i + 1
end
return t