gmime r1462 - in trunk: . docs/reference gmime mono tools



Author: fejj
Date: Fri Sep 19 02:30:42 2008
New Revision: 1462
URL: http://svn.gnome.org/viewvc/gmime?rev=1462&view=rev

Log:
2008-09-18  Jeffrey Stedfast  <fejj novell com>

	* gmime/gmime-utils.c (g_mime_utils_header_decode_text): Check if
	rfc2047-workarounds has been enabled at runtime.

	* gmime/gmime.h (GMIME_ENABLE_RFC2047_WORKAROUNDS): New
	g_mime_init() flag so that a programmer can enable rfc2047
	workarounds at runtime.

	* gmime/gmime.c (g_mime_init): Save the init flags.



Modified:
   trunk/ChangeLog
   trunk/docs/reference/gmime-sections.txt
   trunk/gmime/gmime-utils.c
   trunk/gmime/gmime.c
   trunk/gmime/gmime.h
   trunk/mono/Global.custom
   trunk/tools/gmime-port-2-2-to-2-4.sh

Modified: trunk/docs/reference/gmime-sections.txt
==============================================================================
--- trunk/docs/reference/gmime-sections.txt	(original)
+++ trunk/docs/reference/gmime-sections.txt	Fri Sep 19 02:30:42 2008
@@ -1,7 +1,7 @@
 <SECTION>
 <FILE>gmime</FILE>
 GMIME_CHECK_VERSION
-GMIME_INIT_FLAG_UTF8
+GMIME_ENABLE_RFC2047_WORKAROUNDS
 g_mime_init
 g_mime_shutdown
 gmime_major_version

Modified: trunk/gmime/gmime-utils.c
==============================================================================
--- trunk/gmime/gmime-utils.c	(original)
+++ trunk/gmime/gmime-utils.c	Fri Sep 19 02:30:42 2008
@@ -69,6 +69,8 @@
  * and encodings.
  **/
 
+extern gboolean _g_mime_enable_rfc2047_workarounds (void);
+
 #define GMIME_FOLD_PREENCODED  (GMIME_FOLD_LEN / 2)
 
 /* date parser macros */
@@ -1781,6 +1783,7 @@
 char *
 g_mime_utils_header_decode_text (const char *text)
 {
+	gboolean enable_rfc2047_workarounds = _g_mime_enable_rfc2047_workarounds ();
 	register const char *inptr = text;
 	gboolean encoded = FALSE;
 	const char *lwsp, *word;
@@ -1805,46 +1808,46 @@
 			word = inptr;
 			ascii = TRUE;
 			
-#ifdef ENABLE_RFC2047_WORKAROUNDS
-			if (!strncmp (inptr, "=?", 2)) {
-				inptr += 2;
-				
-				/* skip past the charset (if one is even declared, sigh) */
-				while (*inptr && *inptr != '?') {
-					ascii = ascii && is_ascii (*inptr);
-					inptr++;
-				}
-				
-				/* sanity check encoding type */
-				if (inptr[0] != '?' || !strchr ("BbQq", inptr[1]) || inptr[2] != '?')
-					goto non_rfc2047;
-				
-				inptr += 3;
-				
-				/* find the end of the rfc2047 encoded word token */
-				while (*inptr && strncmp (inptr, "?=", 2) != 0) {
-					ascii = ascii && is_ascii (*inptr);
-					inptr++;
-				}
-				
-				if (!strncmp (inptr, "?=", 2))
+			if (enable_rfc2047_workarounds) {
+				if (!strncmp (inptr, "=?", 2)) {
 					inptr += 2;
+					
+					/* skip past the charset (if one is even declared, sigh) */
+					while (*inptr && *inptr != '?') {
+						ascii = ascii && is_ascii (*inptr);
+						inptr++;
+					}
+					
+					/* sanity check encoding type */
+					if (inptr[0] != '?' || !strchr ("BbQq", inptr[1]) || inptr[2] != '?')
+						goto non_rfc2047;
+					
+					inptr += 3;
+					
+					/* find the end of the rfc2047 encoded word token */
+					while (*inptr && strncmp (inptr, "?=", 2) != 0) {
+						ascii = ascii && is_ascii (*inptr);
+						inptr++;
+					}
+					
+					if (!strncmp (inptr, "?=", 2))
+						inptr += 2;
+				} else {
+				non_rfc2047:
+					/* stop if we encounter a possible rfc2047 encoded
+					 * token even if it's inside another word, sigh. */
+					while (*inptr && !is_lwsp (*inptr) &&
+					       strncmp (inptr, "=?", 2) != 0) {
+						ascii = ascii && is_ascii (*inptr);
+						inptr++;
+					}
+				}
 			} else {
-			non_rfc2047:
-				/* stop if we encounter a possible rfc2047 encoded
-				 * token even if it's inside another word, sigh. */
-				while (*inptr && !is_lwsp (*inptr) &&
-				       strncmp (inptr, "=?", 2) != 0) {
+				while (*inptr && !is_lwsp (*inptr)) {
 					ascii = ascii && is_ascii (*inptr);
 					inptr++;
 				}
 			}
-#else
-			while (*inptr && !is_lwsp (*inptr)) {
-				ascii = ascii && is_ascii (*inptr);
-				inptr++;
-			}
-#endif /* ENABLE_RFC2047_WORKAROUNDS */
 			
 			n = (size_t) (inptr - word);
 			if (is_rfc2047_encoded_word (word, n)) {

Modified: trunk/gmime/gmime.c
==============================================================================
--- trunk/gmime/gmime.c	(original)
+++ trunk/gmime/gmime.c	Fri Sep 19 02:30:42 2008
@@ -47,6 +47,7 @@
 const guint gmime_binary_age = 0;
 
 static unsigned int initialized = 0;
+static guint32 enable = 0;
 
 
 /**
@@ -96,6 +97,8 @@
 	tzset ();
 #endif
 	
+	enable = flags;
+	
 	g_type_init ();
 	
 	g_mime_charset_map_init ();
@@ -141,3 +144,10 @@
 	g_mime_charset_map_shutdown ();
 	g_mime_iconv_shutdown ();
 }
+
+
+gboolean
+_g_mime_enable_rfc2047_workarounds (void)
+{
+	return (enable & GMIME_ENABLE_RFC2047_WORKAROUNDS);
+}

Modified: trunk/gmime/gmime.h
==============================================================================
--- trunk/gmime/gmime.h	(original)
+++ trunk/gmime/gmime.h	Fri Sep 19 02:30:42 2008
@@ -124,15 +124,12 @@
 
 
 /**
- * GMIME_INIT_FLAG_UTF8:
+ * GMIME_ENABLE_RFC2047_WORKAROUNDS:
  *
- * Initialization flag to enable UTF-8 interfaces throughout GMime.
- *
- * Note: this flag is really a no-op and remains only for backward
- * compatablity. Interfaces will be UTF-8 whether this flag is used or
- * not.
+ * Initialization flag to enable workarounds for badly formed rfc2047
+ * encoded-words.
  **/
-#define GMIME_INIT_FLAG_UTF8  (1 << 0)
+#define GMIME_ENABLE_RFC2047_WORKAROUNDS  (1 << 0)
 
 void g_mime_init (guint32 flags);
 void g_mime_shutdown (void);

Modified: trunk/mono/Global.custom
==============================================================================
--- trunk/mono/Global.custom	(original)
+++ trunk/mono/Global.custom	Fri Sep 19 02:30:42 2008
@@ -1,15 +1,25 @@
+		public enum InitFlags {
+		       None = 0,
+		       EnableRfc2047Workarounds = (1 << 0),
+		}
+		
 		[DllImport("gmime")]
 		static extern void g_mime_init (int flags);
-	
+		
 		public static void Init ()
 		{
 			g_mime_init (0);
 		}
-
+		
+		public static void Init (InitFlags flags)
+		{
+			g_mime_init ((int) flags);
+		}
+		
 		[DllImport("gmime")]
 		static extern void g_mime_shutdown ();
-	
+		
 		public static void Shutdown ()
 		{
 			g_mime_shutdown ();
-		}
\ No newline at end of file
+		}

Modified: trunk/tools/gmime-port-2-2-to-2-4.sh
==============================================================================
--- trunk/tools/gmime-port-2-2-to-2-4.sh	(original)
+++ trunk/tools/gmime-port-2-2-to-2-4.sh	Fri Sep 19 02:30:42 2008
@@ -3,7 +3,8 @@
 for src in `find . -name "*.[c,h]"`
 do
     echo "Auto-porting '$src' from GMime-2.2 to GMime-2.4..."
-    sed -e "s/GMimeDisposition/GMimeContentDisposition/g" \
+    sed -e "s/GMIME_INIT_FLAG_UTF8/0/g" \
+        -e "s/GMimeDisposition/GMimeContentDisposition/g" \
 	-e "s/GMimePartEncodingType/GMimeContentEncoding/g" \
 	-e "s/GMIME_PART_ENCODING_/GMIME_CONTENT_ENCODING_/g" \
 	-e "s/GMIME_FILTER_CRLF_ENCODE/TRUE/g" \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]