Merge pull request #3239 from archibishop/username-validation-gpodder-login
Validate username for characters not accepted.
This commit is contained in:
commit
abcd6f772e
|
@ -25,6 +25,8 @@ import android.widget.ViewFlipper;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
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.BuildConfig;
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
|
@ -123,6 +125,11 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
|
||||||
final String usernameStr = username.getText().toString();
|
final String usernameStr = username.getText().toString();
|
||||||
final String passwordStr = password.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");
|
if (BuildConfig.DEBUG) Log.d(TAG, "Checking login credentials");
|
||||||
AsyncTask<GpodnetService, Void, Void> authTask = new AsyncTask<GpodnetService, Void, Void>() {
|
AsyncTask<GpodnetService, Void, Void> authTask = new AsyncTask<GpodnetService, Void, Void>() {
|
||||||
|
|
||||||
|
@ -395,4 +402,10 @@ public class GpodnetAuthenticationActivity extends AppCompatActivity {
|
||||||
finish();
|
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_error_descr">An error occurred during syncing:\u0020</string>
|
||||||
<string name="gpodnetsync_pref_report_successful">Successful</string>
|
<string name="gpodnetsync_pref_report_successful">Successful</string>
|
||||||
<string name="gpodnetsync_pref_report_failed">Failed</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 -->
|
<!-- Directory chooser -->
|
||||||
<string name="selected_folder_label">Selected folder:</string>
|
<string name="selected_folder_label">Selected folder:</string>
|
||||||
|
|
Loading…
Reference in New Issue