mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Use regex function from bctoolbox
This commit is contained in:
parent
f4184738c9
commit
895f089eb5
1 changed files with 4 additions and 22 deletions
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#endif
|
||||
|
||||
#include <bctoolbox/crypto.h>
|
||||
#include <bctoolbox/regex.h>
|
||||
|
||||
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneAccountCreatorCbs);
|
||||
|
||||
|
|
@ -91,25 +92,6 @@ static char* _get_identity(const LinphoneAccountCreator *creator) {
|
|||
return identity;
|
||||
}
|
||||
|
||||
static bool_t is_matching_regex(const char *entry, const char* regex) {
|
||||
#if _WIN32
|
||||
return TRUE;
|
||||
#else
|
||||
regex_t regex_pattern;
|
||||
char err_msg[256];
|
||||
int res;
|
||||
res = regcomp(®ex_pattern, regex, REG_EXTENDED | REG_NOSUB);
|
||||
if(res != 0) {
|
||||
regerror(res, ®ex_pattern, err_msg, sizeof(err_msg));
|
||||
ms_error("Could not compile regex '%s: %s", regex, err_msg);
|
||||
return FALSE;
|
||||
}
|
||||
res = regexec(®ex_pattern, entry, 0, NULL, 0);
|
||||
regfree(®ex_pattern);
|
||||
return (res != REG_NOMATCH);
|
||||
#endif
|
||||
}
|
||||
|
||||
LinphoneProxyConfig * linphone_account_creator_create_proxy_config(const LinphoneAccountCreator *creator) {
|
||||
LinphoneAuthInfo *info;
|
||||
LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(creator->core);
|
||||
|
|
@ -359,7 +341,7 @@ LinphoneAccountCreatorUsernameStatus linphone_account_creator_set_username(Linph
|
|||
return LinphoneAccountCreatorUsernameStatusTooLong;
|
||||
} else if (use_phone_number && !linphone_proxy_config_is_phone_number(NULL, username)) {
|
||||
return LinphoneAccountCreatorUsernameStatusInvalid;
|
||||
} else if (regex && !is_matching_regex(username, regex)) {
|
||||
} else if (regex && !bctbx_is_matching_regex(username, regex)) {
|
||||
return LinphoneAccountCreatorUsernameStatusInvalidCharacters;
|
||||
} else if (validate_uri(username, NULL, NULL) != 0) {
|
||||
return LinphoneAccountCreatorUsernameStatusInvalid;
|
||||
|
|
@ -482,10 +464,10 @@ const char * linphone_account_creator_get_display_name(const LinphoneAccountCrea
|
|||
}
|
||||
|
||||
LinphoneAccountCreatorEmailStatus linphone_account_creator_set_email(LinphoneAccountCreator *creator, const char *email) {
|
||||
if (!email || !is_matching_regex(email, "^.+@.+\\..*$")) {
|
||||
if (!email || !bctbx_is_matching_regex(email, "^.+@.+\\..*$")) {
|
||||
return LinphoneAccountCreatorEmailStatusMalformed;
|
||||
}
|
||||
if (!is_matching_regex(email, "^.+@.+\\.[A-Za-z]{2}[A-Za-z]*$")) {
|
||||
if (!bctbx_is_matching_regex(email, "^.+@.+\\.[A-Za-z]{2}[A-Za-z]*$")) {
|
||||
return LinphoneAccountCreatorEmailStatusInvalidCharacters;
|
||||
}
|
||||
set_string(&creator->email, email, TRUE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue