diff options
author | Wagubi Brian <wagubib@gmail.com> | 2019-06-25 10:41:08 +0300 |
---|---|---|
committer | Wagubi Brian <wagubib@gmail.com> | 2019-06-26 04:50:18 +0300 |
commit | 7f1f725bfe787b822eb324c11459b0f8d2a2cd6e (patch) | |
tree | c5ba971ea57ce0329468928a67eb2a231b167aa8 /app/src/main/java/de/danoeh/antennapod/activity/gpoddernet | |
parent | 1580e93b940436b76e2db46fa5501c8f02e38770 (diff) | |
download | AntennaPod-7f1f725bfe787b822eb324c11459b0f8d2a2cd6e.zip |
validate username for characters not accepted.
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/activity/gpoddernet')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java index 8fcdb4371..df21f713d 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/gpoddernet/GpodnetAuthenticationActivity.java @@ -25,6 +25,8 @@ import android.widget.ViewFlipper; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicReference; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import de.danoeh.antennapod.BuildConfig; import de.danoeh.antennapod.R; @@ -123,6 +125,11 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity { final String usernameStr = username.getText().toString(); final String passwordStr = password.getText().toString(); + if (usernameHasUnwantedChars(usernameStr)) { + txtvError.setText(R.string.gpodnetsync_username_characters_error); + txtvError.setVisibility(View.VISIBLE); + return; + } if (BuildConfig.DEBUG) Log.d(TAG, "Checking login credentials"); AsyncTask<GpodnetService, Void, Void> authTask = new AsyncTask<GpodnetService, Void, Void>() { @@ -395,4 +402,10 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity { finish(); } } + + private boolean usernameHasUnwantedChars(String username) { + Pattern special = Pattern.compile("[!@#$%&*()+=|<>?{}\\[\\]~]"); + Matcher containsUnwantedChars = special.matcher(username); + return containsUnwantedChars.find(); + } } |