From f3c19677c237a8f7857cff8d8673227ea49ebebb Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 30 Oct 2013 16:04:24 +0100
Subject: [PATCH] base64: do not fail on trailing new line character

This fixes numerous failing test cases since e17c1b25.
---
 lib/base64.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/lib/base64.c b/lib/base64.c
index 93b8be2..f329f06 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -90,17 +90,22 @@ CURLcode Curl_base64_decode(const char *src,
   unsigned char lastQuantum[3];
   size_t rawlen = 0;
   unsigned char *newstr;
+  unsigned char c;
 
   *outptr = NULL;
   *outlen = 0;
   srcLen = strlen(src);
 
+  if(srcLen && (src[srcLen - 1] == '\n'))
+    /* the string ends with a new line character, which we ignore */
+    --srcLen;
+
   /* Check the length of the input string is valid */
   if(!srcLen || srcLen % 4)
     return CURLE_BAD_CONTENT_ENCODING;
 
   /* Find the position of any = padding characters */
-  while((src[length] != '=') && src[length])
+  while((c = src[length]) && (c != '=') && (c != '\n'))
     length++;
 
   /* A maximum of two = padding characters is allowed */
-- 
1.7.1


