546 |
char *prID = NULL; |
char *prID = NULL; |
547 |
AdmEntry *cat; |
AdmEntry *cat; |
548 |
const char *headerValue; |
const char *headerValue; |
|
char *c; |
|
549 |
struct re_pattern_buffer regex; |
struct re_pattern_buffer regex; |
550 |
struct re_registers regs; |
struct re_registers regs; |
551 |
int i, start, end; |
int i, start, end, idstart; |
552 |
char case_fold[256]; |
char case_fold[256]; |
553 |
char *possiblePrNum; |
char *possiblePrNum; |
554 |
reg_syntax_t old_syntax; |
reg_syntax_t old_syntax; |
568 |
case_fold[i] = tolower(i); |
case_fold[i] = tolower(i); |
569 |
} |
} |
570 |
regex.translate = case_fold; |
regex.translate = case_fold; |
571 |
|
|
572 |
/* look for "category/1234" and "category: 1234" */ |
{ |
573 |
#define PAT "(.*re[ \t]*(\\[[0-9]+\\])?:)?[ \t]*([-a-z0-9_+.]*[:/][ \t]*([0-9]+))" |
const char *const PAT = "\\<((PR[ \t/])|([-a-z0-9_+.]+)/)([0-9]+)"; |
574 |
|
re_compile_pattern (PAT, strlen (PAT), ®ex); |
575 |
re_compile_pattern (PAT, strlen (PAT), ®ex); |
} |
576 |
i = re_match (®ex, headerValue, strlen (headerValue), 0, ®s); |
i = re_match (®ex, headerValue, strlen (headerValue), 0, ®s); |
577 |
regex.translate = NULL; |
regex.translate = NULL; |
578 |
regfree (®ex); |
regfree (®ex); |
583 |
return NULL; |
return NULL; |
584 |
} |
} |
585 |
|
|
586 |
start = regs.start[3]; |
start = regs.start[0]; |
587 |
end = regs.end[3]; |
end = regs.end[0]; |
588 |
|
idstart = regs.start[4] - start; |
589 |
|
|
590 |
free (regs.start); |
free (regs.start); |
591 |
free (regs.end); |
free (regs.end); |
594 |
memcpy (possiblePrNum, headerValue + start, end - start); |
memcpy (possiblePrNum, headerValue + start, end - start); |
595 |
possiblePrNum[end - start] = '\0'; |
possiblePrNum[end - start] = '\0'; |
596 |
|
|
597 |
c = strchr (possiblePrNum, '/'); |
*(possiblePrNum + idstart - 1) = '\0'; |
|
if (c == NULL) |
|
|
{ |
|
|
c = strchr (possiblePrNum, ':'); |
|
|
} |
|
|
|
|
|
if (c != NULL) |
|
|
{ |
|
|
*c = '\0'; |
|
598 |
|
|
599 |
/* See if the category exists: */ |
/* See if the category exists: */ |
600 |
cat = get_adm_record (CATEGORY (pr->database), possiblePrNum); |
cat = get_adm_record (CATEGORY (pr->database), possiblePrNum); |
601 |
|
|
602 |
/* If no such category, then this is not a reply to a valid |
/* If no such category, then this is not a reply to a valid |
603 |
* problem report. This situtation can arise, for example, when |
* problem report. This situtation can arise, for example, when |
604 |
* someone has the string "OS/2" in their Subject header. |
* someone has the string "OS/2" in their Subject header. |
605 |
*/ |
*/ |
606 |
/* Folks often send in "pr/1234" instead of a valid category */ |
/* Folks often send in "pr/1234" instead of a valid category */ |
607 |
if ((cat != NULL) || (strcasecmp(possiblePrNum, "pr") == 0)) |
if ((cat != NULL) || (strcasecmp (possiblePrNum, "pr") == 0)) |
608 |
{ |
{ |
609 |
/* We only needed res, never cat, so free cat. */ |
/* We only needed res, never cat, so free cat. */ |
610 |
free_adm_entry (cat); |
free_adm_entry (cat); |
611 |
|
prID = xstrdup (possiblePrNum + idstart); |
|
c++; /* skip sep */ |
|
|
while (*c != '\0' && isspace ((int) *c)) |
|
|
{ |
|
|
c++; |
|
|
} |
|
|
prID = xstrdup (c); |
|
|
} |
|
|
} |
|
|
else |
|
|
{ |
|
|
prID = xstrdup (possiblePrNum); |
|
612 |
} |
} |
613 |
|
|
614 |
free (possiblePrNum); |
free (possiblePrNum); |