]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
ignore semicolon in quoted parts
authorJelte Jansen <jelte@NLnetLabs.nl>
Thu, 10 Jan 2008 12:44:30 +0000 (12:44 +0000)
committerJelte Jansen <jelte@NLnetLabs.nl>
Thu, 10 Jan 2008 12:44:30 +0000 (12:44 +0000)
parse.c
rr.c

diff --git a/parse.c b/parse.c
index 6ca2ac72b8770c237fe99e80aaad2af34518cdc5..c7526860cc9c946b5055fdb58ced2b2fedabe8d7 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -32,11 +32,11 @@ ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *li
 {      
        int c;
        int p; /* 0 -> no parenthese seen, >0 nr of ( seen */
-       int com;
+       int com, quoted;
        char *t;
        size_t i;
        const char *d;
-        const char *del;
+       const char *del;
 
        /* standard delimeters */
        if (!delim) {
@@ -49,7 +49,11 @@ ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *li
        p = 0;
        i = 0;
        com = 0;
+       quoted = 0;
        t = token;
+       if (delim[0] == '"') {
+               quoted = 1;
+       }
        while ((c = getc(f)) != EOF) {
                if (c == '(') {
                        /* this only counts for non-comments */
@@ -74,9 +78,12 @@ ldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *li
                }
 
                /* do something with comments ; */
-               if (c == ';') {
+               if (c == ';' && quoted == 0) {
                        com = 1;
                }
+               if (c == '\"' && com == 0) {
+                       quoted = 1 - quoted;
+               }
 
                if (c == '\n' && com != 0) {
                        /* comments */
@@ -189,11 +196,11 @@ ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit)
 {      
        int c, lc;
        int p; /* 0 -> no parenthese seen, >0 nr of ( seen */
-       int com;
+       int com, quoted;
        char *t;
        size_t i;
        const char *d;
-        const char *del;
+       const char *del;
 
        /* standard delimiters */
        if (!delim) {
@@ -206,8 +213,13 @@ ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit)
        p = 0;
        i = 0;
        com = 0;
+       quoted = 0;
        t = token;
        lc = 0;
+       if (delim[0] == '"') {
+               quoted = 1;
+       }
+
        while ((c = ldns_bgetc(b)) != EOF) {
                if (c == '(') {
                        p++;
@@ -226,9 +238,12 @@ ldns_bget_token(ldns_buffer *b, char *token, const char *delim, size_t limit)
                }
 
                /* do something with comments ; */
-               if (c == ';') {
+               if (c == ';' && quoted == 0) {
                        com = 1;
                }
+               if (c == '"' && com == 0) {
+                       quoted = 1 - quoted;
+               }
 
                if (c == '\n' && com != 0) {
                        /* comments */
diff --git a/rr.c b/rr.c
index 193e7108c7bb2645cbc376f494fa28a31a543eb2..8dac64d26b5f4556f6131dad4c9d47dac69a227b 100644 (file)
--- a/rr.c
+++ b/rr.c
@@ -366,17 +366,19 @@ ldns_rr_new_frm_str(ldns_rr **newrr, const char *str, uint32_t default_ttl, ldns
                                        while (*(ldns_buffer_current(rd_buf)) == ' ') {
                                                ldns_buffer_skip(rd_buf, 1);
                                        }
+
                                        if (*(ldns_buffer_current(rd_buf)) == '\"') {
                                                delimiters = "\"\0";
                                                ldns_buffer_skip(rd_buf, 1);
                                        }
+
                                        quoted = true;
                                }
 
                                /* because number of fields can be variable, we can't
                                   rely on _maximum() only */
                                if ((c = ldns_bget_token(rd_buf, rd, delimiters, 
-                                                               LDNS_MAX_RDFLEN)) != -1) {
+                                                                       LDNS_MAX_RDFLEN)) != -1) {
                                        /* hmmz, rfc3597 specifies that any type can be represented with
                                         * \# method, which can contain spaces...
                                         * it does specify size though...