validate username for characters not accepted.
This commit is contained in:
parent
1580e93b94
commit
7f1f725bfe
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -642,6 +642,7 @@
|
|||
<string name="gpodnetsync_error_descr">An error occurred during syncing:\u0020</string>
|
||||
<string name="gpodnetsync_pref_report_successful">Successful</string>
|
||||
<string name="gpodnetsync_pref_report_failed">Failed</string>
|
||||
<string name="gpodnetsync_username_characters_error">Usernames may only contain letters, digits, hyphens and underscores.</string>
|
||||
|
||||
<!-- Directory chooser -->
|
||||
<string name="selected_folder_label">Selected folder:</string>
|
||||
|
|
Loading…
Reference in New Issue