mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-27 16:09:20 +00:00
Use regex function from bctoolbox (retrofit of commit 895f08)
This commit is contained in:
parent
6581df0c49
commit
c21de55c48
1 changed files with 4 additions and 26 deletions
|
|
@ -24,11 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "c-wrapper/c-wrapper.h"
|
||||
#include "dial-plan/dial-plan.h"
|
||||
|
||||
#if !_WIN32
|
||||
#include "regex.h"
|
||||
#endif
|
||||
|
||||
#include <bctoolbox/crypto.h>
|
||||
#include <bctoolbox/regex.h>
|
||||
|
||||
// TODO: From coreapi. Remove me later.
|
||||
#include "private.h"
|
||||
|
|
@ -112,25 +109,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);
|
||||
|
|
@ -383,7 +361,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;
|
||||
|
|
@ -506,10 +484,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