[gmime: 4/10] blockquote: catch '> >' type quotes and handle empty lines



commit bbb52d46f451c904083b9d5404ff8a5853e7676d
Author: Gaute Hope <eg gaute vetsj com>
Date:   Mon Feb 13 09:25:58 2017 +0100

    blockquote: catch '>   >' type quotes and handle empty lines

 gmime/gmime-filter-html.c |   35 ++++++++++++++++++++++-------------
 gmime/gmime-filter-html.h |    1 +
 2 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/gmime/gmime-filter-html.c b/gmime/gmime-filter-html.c
index 71f6c79..26e03e4 100644
--- a/gmime/gmime-filter-html.c
+++ b/gmime/gmime-filter-html.c
@@ -185,20 +185,29 @@ check_size (GMimeFilter *filter, char *outptr, char **outend, size_t len)
 static int
 citation_depth (const char *in, const char *inend)
 {
-       register char *inptr = in;
-       /* check that it isn't an escaped From line */
-       if (!strncmp (inptr, ">From", 5))
-               return inptr;
-       while (inptr < inend && *inptr != '\n') {
-               if (*inptr == ' ')
-                       inptr++;
-               if (inptr >= inend || *inptr != '>')
-                       break;
-               inptr++;
-       }
-       return inptr;
-}
+       register const char *inptr = in;
+       int depth = 0;
+
+  if (in >= inend) return 0;
 
+       /* check that it isn't an escaped From line */
+       if (!strncmp (inptr, ">From", 5))
+               return 0;
+
+       while (inptr < inend && *inptr != '\n') {
+
+    /* remove an arbitrary number of spaces between '>' and next '>' */
+               while (*inptr == ' ' && inptr < inend)
+                       inptr++;
+
+               if (inptr >= inend || *inptr++ != '>')
+                       break;
+
+               depth++;
+       }
+
+       return depth;
+}
 
 static char *
 citation_cut (char *in, const char *inend)
diff --git a/gmime/gmime-filter-html.h b/gmime/gmime-filter-html.h
index bbc000e..940a4a1 100644
--- a/gmime/gmime-filter-html.h
+++ b/gmime/gmime-filter-html.h
@@ -1,6 +1,7 @@
 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 /*  GMime
  *  Copyright (C) 2000-2014 Jeffrey Stedfast
+ *  Copyright (C) 2016      Gaute Hope
  *
  *  This library is free software; you can redistribute it and/or
  *  modify it under the terms of the GNU Lesser General Public License


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