mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
block server entries in AccountSetupIncoming.java and AccountSetupOutgoing.java that are not valid domain names.
This commit is contained in:
parent
b877a52b01
commit
171648aa41
@ -10,6 +10,7 @@ import java.util.Date;
|
|||||||
import com.fsck.k9.codec.binary.Base64;
|
import com.fsck.k9.codec.binary.Base64;
|
||||||
|
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Utility {
|
public class Utility {
|
||||||
@ -76,10 +77,21 @@ public class Utility {
|
|||||||
return view.getText() != null && view.getText().length() > 0;
|
return view.getText() != null && view.getText().length() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean requiredFieldValid(Editable s) {
|
public static boolean requiredFieldValid(Editable s) {
|
||||||
return s != null && s.length() > 0;
|
return s != null && s.length() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean domainFieldValid(EditText view) {
|
||||||
|
if (view.getText() != null) {
|
||||||
|
String s = view.getText().toString();
|
||||||
|
if (s.matches("^([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}$")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the given string starts and ends with the double quote character. The string is not modified in any way except to add the
|
* Ensures that the given string starts and ends with the double quote character. The string is not modified in any way except to add the
|
||||||
* double quote character to start and end if it's not already there.
|
* double quote character to start and end if it's not already there.
|
||||||
@ -173,4 +185,5 @@ public class Utility {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import java.net.URI;
|
|||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
@ -254,7 +256,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
|
|||||||
mNextButton
|
mNextButton
|
||||||
.setEnabled(Utility.requiredFieldValid(mUsernameView)
|
.setEnabled(Utility.requiredFieldValid(mUsernameView)
|
||||||
&& Utility.requiredFieldValid(mPasswordView)
|
&& Utility.requiredFieldValid(mPasswordView)
|
||||||
&& Utility.requiredFieldValid(mServerView)
|
&& Utility.domainFieldValid(mServerView)
|
||||||
&& Utility.requiredFieldValid(mPortView));
|
&& Utility.requiredFieldValid(mPortView));
|
||||||
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
|
||||||
}
|
}
|
||||||
@ -326,6 +328,7 @@ public class AccountSetupIncoming extends Activity implements OnClickListener {
|
|||||||
|
|
||||||
mAccount.setDeletePolicy((Integer)((SpinnerOption)mDeletePolicyView.getSelectedItem()).value);
|
mAccount.setDeletePolicy((Integer)((SpinnerOption)mDeletePolicyView.getSelectedItem()).value);
|
||||||
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
|
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, true, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
@ -222,7 +222,7 @@ public class AccountSetupOutgoing extends Activity implements OnClickListener,
|
|||||||
private void validateFields() {
|
private void validateFields() {
|
||||||
mNextButton
|
mNextButton
|
||||||
.setEnabled(
|
.setEnabled(
|
||||||
Utility.requiredFieldValid(mServerView) &&
|
Utility.domainFieldValid(mServerView) &&
|
||||||
Utility.requiredFieldValid(mPortView) &&
|
Utility.requiredFieldValid(mPortView) &&
|
||||||
(!mRequireLoginView.isChecked() ||
|
(!mRequireLoginView.isChecked() ||
|
||||||
(Utility.requiredFieldValid(mUsernameView) &&
|
(Utility.requiredFieldValid(mUsernameView) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user