diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-03 15:41:44 +0200 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2018-05-03 19:15:09 -0500 |
commit | b276833b333824689b96abd7e32d147e4ee592d5 (patch) | |
tree | b72aca93641100adec13bcbe66876f18376aee32 /app/src/main/java/com/wireguard/config/Config.java | |
parent | global: fix up copyrights (diff) | |
download | wireguard-android-b276833b333824689b96abd7e32d147e4ee592d5.tar.xz wireguard-android-b276833b333824689b96abd7e32d147e4ee592d5.zip |
config: loosen parser to match reality
Mid-line comments, mixed case.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main/java/com/wireguard/config/Config.java')
-rw-r--r-- | app/src/main/java/com/wireguard/config/Config.java | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/app/src/main/java/com/wireguard/config/Config.java b/app/src/main/java/com/wireguard/config/Config.java index f2bcd2fe..2b6b0705 100644 --- a/app/src/main/java/com/wireguard/config/Config.java +++ b/app/src/main/java/com/wireguard/config/Config.java @@ -41,12 +41,16 @@ public class Config { String line; boolean inInterfaceSection = false; while ((line = reader.readLine()) != null) { - if (line.isEmpty() || line.startsWith("#")) + final int commentIndex = line.indexOf('#'); + if (commentIndex != -1) + line = line.substring(0, commentIndex); + line = line.trim(); + if (line.isEmpty()) continue; - if ("[Interface]".equals(line)) { + if ("[Interface]".toLowerCase().equals(line.toLowerCase())) { currentPeer = null; inInterfaceSection = true; - } else if ("[Peer]".equals(line)) { + } else if ("[Peer]".toLowerCase().equals(line.toLowerCase())) { currentPeer = new Peer(); config.peers.add(currentPeer); inInterfaceSection = false; |