From 1544debc9f6ecccebdca94db00abb5f4703f5f52 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 24 Feb 2003 03:15:54 +0000 Subject: [PATCH] MFH --- ext/standard/file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ext/standard/file.c b/ext/standard/file.c index e565f9f00c..dfd1e1e3da 100644 --- a/ext/standard/file.c +++ b/ext/standard/file.c @@ -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++; -- 2.50.1