Browse Source

Merge pull request #423 from Logan007/cntRegExp

removed begin and end from reg exp
pull/424/head
Luca Deri 4 years ago
committed by GitHub
parent
commit
e3dd4fb9b9
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      community.list
  2. 12
      src/n2n_regex.c
  3. 2
      src/sn.c

6
community.list

@ -13,15 +13,13 @@ netleo
ntop[0-1][0-9]
#
# * Note that fixed-name communities may not contain one of the following characters
# . ^ $ * + ? [ ] \
# . * + ? [ ] \
# as otherwise, they are interpreted as regular expression
#
# * Only fixed-name communities are supported for header encryption (-H)
#
# * Regular expression support the following placeholders
# '.' Dot, matches any character (meaningless, as full matches only)
# '^' Start anchor, matches beginning of string (meaningless, as full matches only)
# '$' End anchor, matches end of string
# '.' Dot, matches any character
# '*' Asterisk, match zero or more (greedy)
# '+' Plus, match one or more (greedy)
# '?' Question, match zero or one (non-greedy)

12
src/n2n_regex.c

@ -30,8 +30,8 @@
* Supports:
* ---------
* '.' Dot, matches any character
* '^' Start anchor, matches beginning of string
* '$' End anchor, matches end of string
* '^' Start anchor, matches beginning of string -- NOTE: currently disabled (checking for full matches anyway)
* '$' End anchor, matches end of string -- NOTE: currently disabled (checking for full matches anyway)
* '*' Asterisk, match zero or more (greedy)
* '+' Plus, match one or more (greedy)
* '?' Question, match zero or one (non-greedy)
@ -154,8 +154,8 @@ re_t re_compile(const char* pattern)
switch (c)
{
/* Meta-characters: */
case '^': { re_compiled[j].type = BEGIN; } break;
case '$': { re_compiled[j].type = END; } break;
// case '^': { re_compiled[j].type = BEGIN; } break; <-- disabled (always full matches)
// case '$': { re_compiled[j].type = END; } break; <-- disabled (always full matches)
case '.': { re_compiled[j].type = DOT; } break;
case '*': { re_compiled[j].type = STAR; } break;
case '+': { re_compiled[j].type = PLUS; } break;
@ -180,7 +180,7 @@ re_t re_compile(const char* pattern)
case 's': { re_compiled[j].type = WHITESPACE; } break;
case 'S': { re_compiled[j].type = NOT_WHITESPACE; } break;
/* Escaped character, e.g. '.' or '$' */
/* Escaped character, e.g. '.' */
default:
{
re_compiled[j].type = CHAR;
@ -266,7 +266,7 @@ re_t re_compile(const char* pattern)
void re_print(regex_t* pattern)
{
const char* types[] = { "UNUSED", "DOT", "BEGIN", "END", "QUESTIONMARK", "STAR", "PLUS", "CHAR", "CHAR_CLASS", "INV_CHAR_CLASS", "DIGIT", "NOT_DIGIT", "ALPHA", "NOT_ALPHA", "WHITESPACE", "NOT_WHITESPACE", "BRANCH" };
const char* types[] = { "UNUSED", "DOT", "BEGIN", "END", "QUESTIONMARK", "STAR", "PLUS", "CHAR", "CHAR_CLASS", "INV_CHAR_CLASS", "DIGIT", "NOT_DIGIT", "ALPHA", "NOT_ALPHA", "WHITESPACE" , "NOT_WHITESPACE", /* "BRANCH" */ };
int i;
int j;

2
src/sn.c

@ -76,7 +76,7 @@ static int load_allowed_sn_community(n2n_sn_t *sss, char *path) {
has_net = ( sscanf (line, "%s %s", cmn_str, net_str) == 2 );
// if it contains typical characters...
if(NULL != strpbrk(cmn_str, ".^$*+?[]\\")) {
if(NULL != strpbrk(cmn_str, ".*+?[]\\")) {
// ...it is treated as regular expression
re = (struct sn_community_regular_expression*)calloc(1,sizeof(struct sn_community_regular_expression));
if (re) {

Loading…
Cancel
Save