Browse Source

Use English lower casing

In Turkish, I becomes ı instead of i, which is a problem when matching
things like "AllowedIPs".

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
master
Jason A. Donenfeld 5 years ago
parent
commit
a641a093ad
5 changed files with 14 additions and 8 deletions
  1. +2
    -1
      app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java
  2. +4
    -3
      app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
  3. +4
    -2
      app/src/main/java/com/wireguard/android/preference/VersionPreference.java
  4. +2
    -1
      app/src/main/java/com/wireguard/config/Interface.java
  5. +2
    -1
      app/src/main/java/com/wireguard/config/Peer.java

+ 2
- 1
app/src/main/java/com/wireguard/android/backend/WgQuickBackend.java View File

@@ -21,6 +21,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;


@@ -117,7 +118,7 @@ public final class WgQuickBackend implements Backend {
stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8)); stream.write(config.toWgQuickString().getBytes(StandardCharsets.UTF_8));
} }
String command = String.format("wg-quick %s '%s'", String command = String.format("wg-quick %s '%s'",
state.toString().toLowerCase(), tempFile.getAbsolutePath());
state.toString().toLowerCase(Locale.ENGLISH), tempFile.getAbsolutePath());
if (state == State.UP) if (state == State.UP)
command = "cat /sys/module/wireguard/version && " + command; command = "cat /sys/module/wireguard/version && " + command;
final int result = Application.getRootShell().run(null, command); final int result = Application.getRootShell().run(null, command);


+ 4
- 3
app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java View File

@@ -53,6 +53,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;


@@ -117,8 +118,8 @@ public class TunnelListFragment extends BaseFragment {
throw new IllegalArgumentException("Illegal file name: " + name); throw new IllegalArgumentException("Illegal file name: " + name);
name = name.substring(idx + 1); name = name.substring(idx + 1);
} }
boolean isZip = name.toLowerCase().endsWith(".zip");
if (name.toLowerCase().endsWith(".conf"))
boolean isZip = name.toLowerCase(Locale.ENGLISH).endsWith(".zip");
if (name.toLowerCase(Locale.ENGLISH).endsWith(".conf"))
name = name.substring(0, name.length() - ".conf".length()); name = name.substring(0, name.length() - ".conf".length());
else if (!isZip) else if (!isZip)
throw new IllegalArgumentException("File must be .conf or .zip"); throw new IllegalArgumentException("File must be .conf or .zip");
@@ -137,7 +138,7 @@ public class TunnelListFragment extends BaseFragment {
continue; continue;
name = name.substring(name.lastIndexOf('/') + 1); name = name.substring(name.lastIndexOf('/') + 1);
} }
if (name.toLowerCase().endsWith(".conf"))
if (name.toLowerCase(Locale.ENGLISH).endsWith(".conf"))
name = name.substring(0, name.length() - ".conf".length()); name = name.substring(0, name.length() - ".conf".length());
else else
continue; continue;


+ 4
- 2
app/src/main/java/com/wireguard/android/preference/VersionPreference.java View File

@@ -17,6 +17,8 @@ import com.wireguard.android.Application;
import com.wireguard.android.BuildConfig; import com.wireguard.android.BuildConfig;
import com.wireguard.android.R; import com.wireguard.android.R;


import java.util.Locale;

public class VersionPreference extends Preference { public class VersionPreference extends Preference {
@Nullable private String versionSummary; @Nullable private String versionSummary;


@@ -24,11 +26,11 @@ public class VersionPreference extends Preference {
super(context, attrs); super(context, attrs);


Application.getBackendAsync().thenAccept(backend -> { Application.getBackendAsync().thenAccept(backend -> {
versionSummary = getContext().getString(R.string.version_summary_checking, backend.getTypeName().toLowerCase());
versionSummary = getContext().getString(R.string.version_summary_checking, backend.getTypeName().toLowerCase(Locale.ENGLISH));
Application.getAsyncWorker().supplyAsync(backend::getVersion).whenComplete((version, exception) -> { Application.getAsyncWorker().supplyAsync(backend::getVersion).whenComplete((version, exception) -> {
versionSummary = exception == null versionSummary = exception == null
? getContext().getString(R.string.version_summary, backend.getTypeName(), version) ? getContext().getString(R.string.version_summary, backend.getTypeName(), version)
: getContext().getString(R.string.version_summary_unknown, backend.getTypeName().toLowerCase());
: getContext().getString(R.string.version_summary_unknown, backend.getTypeName().toLowerCase(Locale.ENGLISH));
notifyChanged(); notifyChanged();
}); });
}); });


+ 2
- 1
app/src/main/java/com/wireguard/config/Interface.java View File

@@ -15,6 +15,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;


@@ -64,7 +65,7 @@ public final class Interface {
for (final CharSequence line : lines) { for (final CharSequence line : lines) {
final Attribute attribute = Attribute.parse(line) final Attribute attribute = Attribute.parse(line)
.orElseThrow(() -> new ParseException("[Interface]", line, "Syntax error")); .orElseThrow(() -> new ParseException("[Interface]", line, "Syntax error"));
switch (attribute.getKey().toLowerCase()) {
switch (attribute.getKey().toLowerCase(Locale.ENGLISH)) {
case "address": case "address":
builder.parseAddresses(attribute.getValue()); builder.parseAddresses(attribute.getValue());
break; break;


+ 2
- 1
app/src/main/java/com/wireguard/config/Peer.java View File

@@ -13,6 +13,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;


@@ -54,7 +55,7 @@ public final class Peer {
for (final CharSequence line : lines) { for (final CharSequence line : lines) {
final Attribute attribute = Attribute.parse(line) final Attribute attribute = Attribute.parse(line)
.orElseThrow(() -> new ParseException("[Peer]", line, "Syntax error")); .orElseThrow(() -> new ParseException("[Peer]", line, "Syntax error"));
switch (attribute.getKey().toLowerCase()) {
switch (attribute.getKey().toLowerCase(Locale.ENGLISH)) {
case "allowedips": case "allowedips":
builder.parseAllowedIPs(attribute.getValue()); builder.parseAllowedIPs(attribute.getValue());
break; break;


Loading…
Cancel
Save