author | zecke <zecke> | 2003-08-29 18:02:09 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-08-29 18:02:09 (UTC) |
commit | 885c645ee48ae53467e244521c011c73bc106afb (patch) (unidiff) | |
tree | 9024be25b2503788d3aa77b7a86b89e543cdd865 | |
parent | ed6da2303a8fabec50991365914f0e4d20a21ea6 (diff) | |
download | opie-885c645ee48ae53467e244521c011c73bc106afb.zip opie-885c645ee48ae53467e244521c011c73bc106afb.tar.gz opie-885c645ee48ae53467e244521c011c73bc106afb.tar.bz2 |
Fixes for base64 decoding and encoding of vCard
-rw-r--r-- | library/backend/vcc.y | 25 | ||||
-rw-r--r-- | library/backend/vcc_yacc.cpp | 29 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 5 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 4 |
4 files changed, 28 insertions, 35 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y index 4c79368..bec2955 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y | |||
@@ -441,7 +441,7 @@ static void enterProps(const char *s) | |||
441 | 441 | ||
442 | static void enterAttr(const char *s1, const char *s2) | 442 | static void enterAttr(const char *s1, const char *s2) |
443 | { | 443 | { |
444 | const char *p1, *p2; | 444 | const char *p1, *p2=0; |
445 | p1 = lookupProp_(s1); | 445 | p1 = lookupProp_(s1); |
446 | if (s2) { | 446 | if (s2) { |
447 | VObject *a; | 447 | VObject *a; |
@@ -813,7 +813,7 @@ static void finiLex() { | |||
813 | /* This parses and converts the base64 format for binary encoding into | 813 | /* This parses and converts the base64 format for binary encoding into |
814 | * a decoded buffer (allocated with new). See RFC 1521. | 814 | * a decoded buffer (allocated with new). See RFC 1521. |
815 | */ | 815 | */ |
816 | static char * lexGetDataFromBase64() | 816 | static int lexGetDataFromBase64() |
817 | { | 817 | { |
818 | unsigned long bytesLen = 0, bytesMax = 0; | 818 | unsigned long bytesLen = 0, bytesMax = 0; |
819 | int quadIx = 0, pad = 0; | 819 | int quadIx = 0, pad = 0; |
@@ -826,6 +826,7 @@ static char * lexGetDataFromBase64() | |||
826 | DBG_(("db: lexGetDataFromBase64\n")); | 826 | DBG_(("db: lexGetDataFromBase64\n")); |
827 | while (1) { | 827 | while (1) { |
828 | c = lexGetc(); | 828 | c = lexGetc(); |
829 | lexSkipWhite(); | ||
829 | if (c == '\n') { | 830 | if (c == '\n') { |
830 | ++mime_lineNum; | 831 | ++mime_lineNum; |
831 | if (lexLookahead() == '\n') { | 832 | if (lexLookahead() == '\n') { |
@@ -848,8 +849,6 @@ static char * lexGetDataFromBase64() | |||
848 | else if (c == '=') { | 849 | else if (c == '=') { |
849 | b = 0; | 850 | b = 0; |
850 | pad++; | 851 | pad++; |
851 | } else if ((c == ' ') || (c == '\t')) { | ||
852 | continue; | ||
853 | } else { /* error condition */ | 852 | } else { /* error condition */ |
854 | if (bytes) free(bytes); | 853 | if (bytes) free(bytes); |
855 | else if (oldBytes) free(oldBytes); | 854 | else if (oldBytes) free(oldBytes); |
@@ -858,14 +857,17 @@ static char * lexGetDataFromBase64() | |||
858 | if (c != EOF) { | 857 | if (c != EOF) { |
859 | c = lexGetc(); | 858 | c = lexGetc(); |
860 | while (c != EOF) { | 859 | while (c != EOF) { |
861 | if (c == '\n' && lexLookahead() == '\n') { | 860 | if (c == '\n') { |
861 | lexSkipWhite(); | ||
862 | if(lexLookahead() == '\n') { | ||
862 | ++mime_lineNum; | 863 | ++mime_lineNum; |
863 | break; | 864 | break; |
864 | } | 865 | } |
866 | } | ||
865 | c = lexGetc(); | 867 | c = lexGetc(); |
866 | } | 868 | } |
867 | } | 869 | } |
868 | return NULL; | 870 | return c != EOF; |
869 | } | 871 | } |
870 | trip = (trip << 6) | b; | 872 | trip = (trip << 6) | b; |
871 | if (++quadIx == 4) { | 873 | if (++quadIx == 4) { |
@@ -911,7 +913,7 @@ static char * lexGetDataFromBase64() | |||
911 | setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); | 913 | setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); |
912 | free(oldBytes); | 914 | free(oldBytes); |
913 | } | 915 | } |
914 | return 0; | 916 | return bytesLen; |
915 | } | 917 | } |
916 | 918 | ||
917 | static int match_begin_end_name(int end) { | 919 | static int match_begin_end_name(int end) { |
@@ -942,7 +944,7 @@ static char* lexGetQuotedPrintable() | |||
942 | c = lexLookahead(); | 944 | c = lexLookahead(); |
943 | lexClearToken(); | 945 | lexClearToken(); |
944 | 946 | ||
945 | while (c != EOF && c != ';') { | 947 | while (c != EOF && (c != ';' || !fieldedProp)) { |
946 | if (c == '\n') { | 948 | if (c == '\n') { |
947 | // break, leave '\n' on remaining chars. | 949 | // break, leave '\n' on remaining chars. |
948 | break; | 950 | break; |
@@ -1032,11 +1034,8 @@ static int yylex() { | |||
1032 | lexPushLookaheadc(c); | 1034 | lexPushLookaheadc(c); |
1033 | if (lexWithinMode(L_BASE64)) { | 1035 | if (lexWithinMode(L_BASE64)) { |
1034 | /* get each char and convert to bin on the fly... */ | 1036 | /* get each char and convert to bin on the fly... */ |
1035 | p = lexGetDataFromBase64(); | 1037 | yylval.str = NULL; |
1036 | #if 0 | 1038 | return lexGetDataFromBase64() ? STRING : 0; |
1037 | yylval.str = p; | ||
1038 | return STRING; | ||
1039 | #endif | ||
1040 | } | 1039 | } |
1041 | else if (lexWithinMode(L_QUOTED_PRINTABLE)) { | 1040 | else if (lexWithinMode(L_QUOTED_PRINTABLE)) { |
1042 | p = lexGetQuotedPrintable(); | 1041 | p = lexGetQuotedPrintable(); |
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp index 5f53aef..4006bc2 100644 --- a/library/backend/vcc_yacc.cpp +++ b/library/backend/vcc_yacc.cpp | |||
@@ -461,7 +461,7 @@ static void enterProps(const char *s) | |||
461 | 461 | ||
462 | static void enterAttr(const char *s1, const char *s2) | 462 | static void enterAttr(const char *s1, const char *s2) |
463 | { | 463 | { |
464 | const char *p1, *p2; | 464 | const char *p1, *p2=0; |
465 | p1 = lookupProp_(s1); | 465 | p1 = lookupProp_(s1); |
466 | if (s2) { | 466 | if (s2) { |
467 | VObject *a; | 467 | VObject *a; |
@@ -833,7 +833,7 @@ static void finiLex() { | |||
833 | /* This parses and converts the base64 format for binary encoding into | 833 | /* This parses and converts the base64 format for binary encoding into |
834 | * a decoded buffer (allocated with new). See RFC 1521. | 834 | * a decoded buffer (allocated with new). See RFC 1521. |
835 | */ | 835 | */ |
836 | static char * lexGetDataFromBase64() | 836 | static int lexGetDataFromBase64() |
837 | { | 837 | { |
838 | unsigned long bytesLen = 0, bytesMax = 0; | 838 | unsigned long bytesLen = 0, bytesMax = 0; |
839 | int quadIx = 0, pad = 0; | 839 | int quadIx = 0, pad = 0; |
@@ -846,6 +846,7 @@ static char * lexGetDataFromBase64() | |||
846 | DBG_(("db: lexGetDataFromBase64\n")); | 846 | DBG_(("db: lexGetDataFromBase64\n")); |
847 | while (1) { | 847 | while (1) { |
848 | c = lexGetc(); | 848 | c = lexGetc(); |
849 | lexSkipWhite(); | ||
849 | if (c == '\n') { | 850 | if (c == '\n') { |
850 | ++mime_lineNum; | 851 | ++mime_lineNum; |
851 | if (lexLookahead() == '\n') { | 852 | if (lexLookahead() == '\n') { |
@@ -868,8 +869,6 @@ static char * lexGetDataFromBase64() | |||
868 | else if (c == '=') { | 869 | else if (c == '=') { |
869 | b = 0; | 870 | b = 0; |
870 | pad++; | 871 | pad++; |
871 | } else if ((c == ' ') || (c == '\t')) { | ||
872 | continue; | ||
873 | } else { /* error condition */ | 872 | } else { /* error condition */ |
874 | if (bytes) free(bytes); | 873 | if (bytes) free(bytes); |
875 | else if (oldBytes) free(oldBytes); | 874 | else if (oldBytes) free(oldBytes); |
@@ -878,14 +877,17 @@ static char * lexGetDataFromBase64() | |||
878 | if (c != EOF) { | 877 | if (c != EOF) { |
879 | c = lexGetc(); | 878 | c = lexGetc(); |
880 | while (c != EOF) { | 879 | while (c != EOF) { |
881 | if (c == '\n' && lexLookahead() == '\n') { | 880 | if (c == '\n') { |
881 | lexSkipWhite(); | ||
882 | if(lexLookahead() == '\n') { | ||
882 | ++mime_lineNum; | 883 | ++mime_lineNum; |
883 | break; | 884 | break; |
884 | } | 885 | } |
886 | } | ||
885 | c = lexGetc(); | 887 | c = lexGetc(); |
886 | } | 888 | } |
887 | } | 889 | } |
888 | return NULL; | 890 | return c != EOF; |
889 | } | 891 | } |
890 | trip = (trip << 6) | b; | 892 | trip = (trip << 6) | b; |
891 | if (++quadIx == 4) { | 893 | if (++quadIx == 4) { |
@@ -931,7 +933,7 @@ static char * lexGetDataFromBase64() | |||
931 | setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); | 933 | setValueWithSize(curProp,oldBytes,(unsigned int)bytesLen); |
932 | free(oldBytes); | 934 | free(oldBytes); |
933 | } | 935 | } |
934 | return 0; | 936 | return bytesLen; |
935 | } | 937 | } |
936 | 938 | ||
937 | static int match_begin_end_name(int end) { | 939 | static int match_begin_end_name(int end) { |
@@ -962,7 +964,7 @@ static char* lexGetQuotedPrintable() | |||
962 | c = lexLookahead(); | 964 | c = lexLookahead(); |
963 | lexClearToken(); | 965 | lexClearToken(); |
964 | 966 | ||
965 | while (c != EOF && c != ';') { | 967 | while (c != EOF && (c != ';' || !fieldedProp)) { |
966 | if (c == '\n') { | 968 | if (c == '\n') { |
967 | // break, leave '\n' on remaining chars. | 969 | // break, leave '\n' on remaining chars. |
968 | break; | 970 | break; |
@@ -1052,11 +1054,8 @@ static int yylex() { | |||
1052 | lexPushLookaheadc(c); | 1054 | lexPushLookaheadc(c); |
1053 | if (lexWithinMode(L_BASE64)) { | 1055 | if (lexWithinMode(L_BASE64)) { |
1054 | /* get each char and convert to bin on the fly... */ | 1056 | /* get each char and convert to bin on the fly... */ |
1055 | p = lexGetDataFromBase64(); | 1057 | yylval.str = NULL; |
1056 | #if 0 | 1058 | return lexGetDataFromBase64() ? STRING : 0; |
1057 | yylval.str = p; | ||
1058 | return STRING; | ||
1059 | #endif | ||
1060 | } | 1059 | } |
1061 | else if (lexWithinMode(L_QUOTED_PRINTABLE)) { | 1060 | else if (lexWithinMode(L_QUOTED_PRINTABLE)) { |
1062 | p = lexGetQuotedPrintable(); | 1061 | p = lexGetQuotedPrintable(); |
@@ -1238,7 +1237,7 @@ void mime_error_(char *s) | |||
1238 | } | 1237 | } |
1239 | } | 1238 | } |
1240 | 1239 | ||
1241 | #line 1240 "y.tab.c" | 1240 | #line 1241 "y.tab.c" |
1242 | #define YYABORT goto yyabort | 1241 | #define YYABORT goto yyabort |
1243 | #define YYREJECT goto yyabort | 1242 | #define YYREJECT goto yyabort |
1244 | #define YYACCEPT goto yyaccept | 1243 | #define YYACCEPT goto yyaccept |
@@ -1538,7 +1537,7 @@ case 45: | |||
1538 | popVObject(); | 1537 | popVObject(); |
1539 | } | 1538 | } |
1540 | break; | 1539 | break; |
1541 | #line 1540 "y.tab.c" | 1540 | #line 1541 "y.tab.c" |
1542 | } | 1541 | } |
1543 | yyssp -= yym; | 1542 | yyssp -= yym; |
1544 | yystate = *yyssp; | 1543 | yystate = *yyssp; |
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index 4c8de70..9263c3a 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -42,9 +42,7 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
42 | * vobject, and convert a vobject into its textual representation. | 42 | * vobject, and convert a vobject into its textual representation. |
43 | */ | 43 | */ |
44 | 44 | ||
45 | #ifndef MWERKS | 45 | #include <stdlib.h> |
46 | #include <malloc.h> | ||
47 | #endif | ||
48 | 46 | ||
49 | #include <qtopia/config.h> | 47 | #include <qtopia/config.h> |
50 | #include "vobject_p.h" | 48 | #include "vobject_p.h" |
@@ -757,7 +755,6 @@ static struct PreDefProp propNames[] = { | |||
757 | { VCPSProp, 0, 0, 0 }, | 755 | { VCPSProp, 0, 0, 0 }, |
758 | { VCPublicKeyProp, 0, 0, 0 }, | 756 | { VCPublicKeyProp, 0, 0, 0 }, |
759 | { VCQPProp, VCQuotedPrintableProp, 0, 0 }, | 757 | { VCQPProp, VCQuotedPrintableProp, 0, 0 }, |
760 | { VCQPProp, VCBase64Prop, 0, 0 }, | ||
761 | { VCQuickTimeProp, 0, 0, 0 }, | 758 | { VCQuickTimeProp, 0, 0, 0 }, |
762 | { VCQuotedPrintableProp, 0, 0, 0 }, | 759 | { VCQuotedPrintableProp, 0, 0, 0 }, |
763 | { VCRDateProp, 0, 0, 0 }, | 760 | { VCRDateProp, 0, 0, 0 }, |
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index f969898..3c9d0d3 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h | |||
@@ -99,9 +99,7 @@ For example: | |||
99 | #define vCalendarMimeType"text/x-vCalendar" | 99 | #define vCalendarMimeType"text/x-vCalendar" |
100 | 100 | ||
101 | #undef DLLEXPORT | 101 | #undef DLLEXPORT |
102 | //#include <qtopia/qpeglobal.h> | 102 | #include <qtopia/global.h> |
103 | #include <qglobal.h> | ||
104 | |||
105 | #if defined(QTOPIA_MAKEDLL) | 103 | #if defined(QTOPIA_MAKEDLL) |
106 | #define DLLEXPORT(t) __declspec(dllexport) t | 104 | #define DLLEXPORT(t) __declspec(dllexport) t |
107 | #elif defined(QTOPIA_DLL) | 105 | #elif defined(QTOPIA_DLL) |