-rw-r--r-- | library/backend/vcc.y | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y index eca7c32..00e8fed 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y @@ -52,2 +52,4 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. /* debugging utilities */ +#define __DEBUG 1
+
#if __DEBUG @@ -137,2 +139,3 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. /**** Global Variables ****/ +int q_DontDecodeBase64Photo = 0;
int mime_lineNum, mime_numErrors; /* yyerror() can use these */ @@ -160,2 +163,3 @@ enum LexMode { L_NORMAL, + L_PARAMWORD,
L_VCARD, @@ -291,6 +295,10 @@ attr: name } - | name EQ name + | name EQ
{ - enterAttr($1,$3); - + lexPushMode(L_PARAMWORD);
+ }
+ name
+ {
+ lexPopMode(0);
+ enterAttr($1,$4);
} @@ -453,6 +461,11 @@ static void enterAttr(const char *s1, const char *s2) addProp(curProp,p1); - if (qstricmp(p1,VCBase64Prop) == 0 || (s2 && qstricmp(p2,VCBase64Prop)==0)) + /* Lookup strings so we can quickly use pointer comparison */
+ static const char* base64 = lookupProp_(VCBase64Prop);
+ static const char* qp = lookupProp_(VCQuotedPrintableProp);
+ static const char* photo = lookupProp_(VCPhotoProp);
+ static const char* encoding = lookupProp_(VCEncodingProp);
+ if ((!q_DontDecodeBase64Photo || vObjectName(curProp) != photo)
+ && (p1 == base64 || p1 == encoding && p2 == base64))
lexPushMode(L_BASE64); - else if (qstricmp(p1,VCQuotedPrintableProp) == 0 - || (s2 && qstricmp(p2,VCQuotedPrintableProp)==0)) + else if (p1 == qp || p1 == encoding && p2 == qp)
lexPushMode(L_QUOTED_PRINTABLE); @@ -643,2 +656,16 @@ static char* lexGetWord() { +static char* lexGetParamWord()
+{
+ int c;
+ lexClearToken();
+ c = lexLookahead();
+ while (c >= ' ' && c < 127 && !strchr("[]:=,.;",c)) {
+ lexAppendc(c);
+ lexSkipLookahead();
+ c = lexLookahead();
+ }
+ lexAppendc(0);
+ return lexStr();
+}
+
static void lexPushLookaheadc(int c) { @@ -1012,2 +1039,3 @@ static int yylex() { int c = lexGetc(); + int c2;
if (c == ';' && fieldedProp) { @@ -1019,9 +1047,8 @@ static int yylex() { } - else if (strchr("\n",c)) { + else if (strchr("\n",c) && (c2 = lexLookahead()) != ' ' && c2 != '\t') {
++mime_lineNum; /* consume all line separator(s) adjacent to each other */ - c = lexLookahead(); - while (strchr("\n",c)) { + while (strchr("\n",c2)) {
lexSkipLookahead(); - c = lexLookahead(); + c2 = lexLookahead();
++mime_lineNum; @@ -1056,4 +1083,6 @@ static int yylex() { } - } - else { + } else if (lexmode == L_PARAMWORD) {
+ yylval.str = lexGetParamWord();
+ return ID;
+ } else {
/* normal mode */ |