summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorArne Schwabe <arne@rfc2549.org>2016-10-03 12:41:30 +0200
committerArne Schwabe <arne@rfc2549.org>2016-10-03 12:41:30 +0200
commitc1544d5cccb4db88a8530b5161e404ea7c2ae22f (patch)
treee09271c52a2af85e070c8856ad5851e91eb7191f /main
parent166da85161efa36269e0a1a492bb4528d5204e89 (diff)
Fix http-proxy-user-pass not embedded correctly in custom options (closes #551)
Diffstat (limited to 'main')
-rw-r--r--main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java10
-rw-r--r--main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java37
2 files changed, 43 insertions, 4 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
index bb7411c0..e0aac552 100644
--- a/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
+++ b/main/src/main/java/de/blinkt/openvpn/core/ConfigParser.java
@@ -6,7 +6,7 @@
package de.blinkt.openvpn.core;
import android.text.TextUtils;
-import android.util.Pair;
+import android.support.v4.util.Pair;
import java.io.BufferedReader;
import java.io.IOException;
@@ -119,6 +119,9 @@ public class ConfigParser {
}
} while (true);
+ if(inlinefile.endsWith("\n"))
+ inlinefile = inlinefile.substring(0, inlinefile.length()-1);
+
args.clear();
args.add(argname);
args.add(inlinefile);
@@ -870,10 +873,9 @@ public class ConfigParser {
for (Vector<String> optionsline : option) {
if (!ignoreThisOption(optionsline)) {
// Check if option had been inlined and inline again
- if (optionsline.size() == 2 && "extra-certs".equals(optionsline.get(0)) ) {
+ if (optionsline.size() == 2 &&
+ ("extra-certs".equals(optionsline.get(0)) || "http-proxy-user-pass".equals(optionsline.get(0)))) {
custom += VpnProfile.insertFileData(optionsline.get(0), optionsline.get(1));
-
-
} else {
for (String arg : optionsline)
custom += VpnProfile.openVpnEscape(arg) + " ";
diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java b/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java
new file mode 100644
index 00000000..560d4fc8
--- /dev/null
+++ b/main/src/test/java/de/blinkt/openvpn/core/TestConfigParser.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2012-2016 Arne Schwabe
+ * Distributed under the GNU GPL v2 with additional terms. For full terms see the file doc/LICENSE.txt
+ */
+
+package de.blinkt.openvpn.core;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import de.blinkt.openvpn.VpnProfile;
+
+/**
+ * Created by arne on 03.10.16.
+ */
+
+public class TestConfigParser {
+
+ String miniconfig = "client\nremote test.blinkt.de\n";
+
+ @Test
+ public void testHttpProxyPass() throws IOException, ConfigParser.ConfigParseError {
+ String httpproxypass = "<http-proxy-user-pass>\n" +
+ "foo\n" +
+ "bar\n" +
+ "</http-proxy-user-pass>\n";
+
+ ConfigParser cp = new ConfigParser();
+ cp.parseConfig(new StringReader(miniconfig + httpproxypass));
+ VpnProfile p = cp.convertProfile();
+ Assert.assertTrue(p.mCustomConfigOptions.contains(httpproxypass));
+
+ }
+}