]> granicus.if.org Git - php/commitdiff
MFH
authorIlia Alshanetsky <iliaa@php.net>
Mon, 24 Feb 2003 03:15:54 +0000 (03:15 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 24 Feb 2003 03:15:54 +0000 (03:15 +0000)
ext/standard/file.c

index e565f9f00cdefd657486be405faab50e5ccc7b9a..dfd1e1e3da5f676689a19c046494d2e3b7b57f76 100644 (file)
@@ -2210,6 +2210,21 @@ PHP_FUNCTION(fgetcsv)
 
                        /* 2A. handle enclosure delimited field */
                        while (*bptr) {
+                               /* we need to determine if the enclosure is 'real' or is it escaped */
+                               if (*(bptr - 1) == '\\') {
+                                       int escape_cnt = 0;
+                                       char *bptr_p = bptr - 2;
+                               
+                                       while (bptr_p > buf && *bptr_p == '\\') {
+                                               escape_cnt++;
+                                               bptr_p--;
+                                       }
+                                       if (!(escape_cnt % 2)) {
+                                               goto normal_char;
+                                               continue;
+                                       }
+                               }
+                       
                                if (*bptr == enclosure) {
                                        /* handle the enclosure */
                                        if ( *(bptr+1) == enclosure) {
@@ -2223,6 +2238,7 @@ PHP_FUNCTION(fgetcsv)
                                                break;  /* .. from handling this field - resumes at 3. */
                                        }
                                } else {
+normal_char:
                                /* normal character */
                                        *tptr++ = *bptr++;