diff options
author | Arne Schwabe <arne@rfc2549.org> | 2022-03-16 14:07:16 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2022-03-16 14:07:16 +0100 |
commit | ee1f7d1c4792d3045e6b52f084c6e95f4645c4ee (patch) | |
tree | 7a34d5451b1ea5a814fa1578931a3f0572b08cf6 | |
parent | 721b39034ca24fafa884516b6af265989511f224 (diff) |
Properly quote strings with ' in them in config/management (closes #1456)
-rw-r--r-- | main/src/main/java/de/blinkt/openvpn/VpnProfile.java | 2 | ||||
-rw-r--r-- | main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java index edbc38ed..00a53565 100644 --- a/main/src/main/java/de/blinkt/openvpn/VpnProfile.java +++ b/main/src/main/java/de/blinkt/openvpn/VpnProfile.java @@ -204,7 +204,7 @@ public class VpnProfile implements Serializable, Cloneable { if (escapedString.equals(unescaped) && !escapedString.contains(" ") && !escapedString.contains("#") && !escapedString.contains(";") - && !escapedString.equals("")) + && !escapedString.equals("") && !escapedString.contains("'")) return unescaped; else return '"' + escapedString + '"'; diff --git a/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java b/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java index 378bc630..e2be04b4 100644 --- a/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java +++ b/main/src/test/java/de/blinkt/openvpn/core/TestConfigGenerator.java @@ -67,6 +67,10 @@ public class TestConfigGenerator { { String uglyPassword = "^OrFg1{G^SS8b4J@B$Y1Dr\\GwG-dw3aBJ/R@WI*doCVP',+:>zjqC[&b6[8=KL:`{l&:i!_4*npE?4k2c^(n>9Tjp~u2Z]l8(y&Gg<-cwR2k=yKK:-%f-ezQ\"^g)[d,kbsu$cqih\\wA~on$~)QSODtip2cd,+->qv,roF*9>6q:lTepm=r?Y-+(K]ERGn\"+AiLj<(R_'BOg:vsh0wh]BQ-PVo534;l%R*FF!+,$?Q00%839(k?E!x0R[Lx6qK\\&"; String escapedUglyPassword = VpnProfile.openVpnEscape(uglyPassword); + + String testWithQuote = "'meinpw"; + String escapedQuote = VpnProfile.openVpnEscape(testWithQuote); + org.junit.Assert.assertEquals("\"'meinpw\"", escapedQuote); } |