Commit Diff
Diff:
acc6cd3b07150e6336bf862acfee7553ad1140a9
bd293faa3a988ed927023b0c907ed813ba06004a
Commit:
bd293faa3a988ed927023b0c907ed813ba06004a
Tree:
24f69de60ffff9af82829527c5569bcf774b5069
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Sun Apr 13 19:46:37 2014 UTC
Message:
* allow escaped quotationmarks in quoted strings, TXT records for example
blob - a040c1c9db7bef8dbc7e00e7653fd1cf6612e59d
blob + 365497f7ac5ad641efa1e81ba714448d2c7c00c3
--- example4.conf
+++ example4.conf
@@ -82,8 +82,8 @@ zone "centroid.eu" {
; balance these two
centroid.eu,balance,3600,62.75.160.180
centroid.eu,balance,3600,192.168.0.24
- centroid.eu,txt,3600,"1234"
- text.centroid.eu,txt,3600",,,,this is valid,,,too,,,"
+ centroid.eu,txt,3600,"1234\"\"1234\"\""
+ text.centroid.eu,txt,3600,",,,,this is valid,,,too,,,"
}
zone "root hints" {
blob - a5252e57cb8a7fb8ac5de5fc4e816d915f933fe8
blob + 0fd1e5774e0159bb8e962bb06d93853024083f56
--- parse.y
+++ parse.y
@@ -58,7 +58,7 @@ typedef struct {
int lineno;
} YYSTYPE;
-static const char rcsid[] = "$Id: parse.y,v 1.6 2014/04/13 12:58:37 pjp Exp $";
+static const char rcsid[] = "$Id: parse.y,v 1.7 2014/04/13 19:46:37 pjp Exp $";
static int version = 0;
static int state = 0;
static uint8_t region = 0;
@@ -87,7 +87,7 @@ extern void slave_shutdown(void);
int get_string(char *buf, int n, FILE *iop);
-int get_quotedstring(char *buf, int n, FILE *iop);
+int get_quotedstring(char *buf, int n);
int get_ip(char *buf, int n, FILE *iop);
struct rrtab * rrlookup(struct rrtab *, char *keyword);
char * check_rr(char *, char *, int, int *);
@@ -991,9 +991,9 @@ yylex()
}
if (c == '"') {
- get_quotedstring(buf, sizeof(buf) - 1, stdin);
+ get_quotedstring(buf, sizeof(buf) - 1);
- if ((cp = strpbrk(buf, "\"\n"))) {
+ if ((cp = strrchr(buf, '"'))) {
cpos = cp - buf;
c = buf[cpos];
buf[cpos] = '\0';
@@ -1120,21 +1120,37 @@ yylex()
}
int
-get_quotedstring(char *buf, int n, FILE *iop)
+get_quotedstring(char *buf, int n)
{
int i, c;
+ int stack = 0;
char *cs;
cs = buf;
for (i = 0; --n > 0; ++i) {
c = lgetc(0);
- if (c == '\n' || c == '"') {
+ if (c == '\n') {
*cs = '\0';
- if (c != '"')
- lungetc(c);
+ lungetc(c);
return (0);
- }
+ } else if (c == '"') {
+ if (stack == 0) {
+ *cs = '\0';
+ return (0);
+ } else {
+ stack--;
+ }
+ } else if (c == '\\') {
+ if (stack == 0) {
+ stack++;
+ continue;
+ } else {
+ stack--;
+ }
+ } else
+ stack = 0;
+
*cs++ = c;
}
@@ -2039,7 +2055,7 @@ int pushback_index = 0;
int
lgetc(int quotec)
{
- int c, next;
+ int c;
if (parsebuf) {
/* Read character from the parsebuffer instead of input. */
@@ -2066,17 +2082,7 @@ lgetc(int quotec)
return (c);
}
- while ((c = getc(file->stream)) == '\\') {
- next = getc(file->stream);
- if (next != '\n') {
- c = next;
- break;
- }
- yylval.lineno = file->lineno;
- file->lineno++;
- }
-
- while (c == EOF) {
+ while ((c = getc(file->stream)) == EOF) {
if (file == topfile || popfile() == EOF)
return (EOF);
c = getc(file->stream);
repomaster@centroid.eu