Bug 1413490 - Base64.cpp: disable the formatting of kBase64DecodeTable & kBase64URLDecodeTable r?erahm draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 01 Nov 2017 11:24:37 +0100
changeset 690042 dfc45f3a1144bbd4314c0dcbded1f9e98e4e51fc
parent 690034 cd7217cf05a2332a8fd7b498767a07b2c31ea657
child 738463 5b94df2d2920a707a9f1c1839b2436b5ccc70e20
push id87182
push userbmo:sledru@mozilla.com
push dateWed, 01 Nov 2017 10:25:02 +0000
reviewerserahm
bugs1413490
milestone58.0a1
Bug 1413490 - Base64.cpp: disable the formatting of kBase64DecodeTable & kBase64URLDecodeTable r?erahm MozReview-Commit-ID: GvvwGp8vlxC
xpcom/io/Base64.cpp
--- a/xpcom/io/Base64.cpp
+++ b/xpcom/io/Base64.cpp
@@ -239,17 +239,19 @@ EncodeInputStream(nsIInputStream* aInput
     *aDest.EndWriting() = '\0';
   }
 
   return NS_OK;
 }
 
 // Maps an encoded character to a value in the Base64 alphabet, per
 // RFC 4648, Table 1. Invalid input characters map to UINT8_MAX.
+
 static const uint8_t kBase64DecodeTable[] = {
+// clang-format off
   /* 0 */  255, 255, 255, 255, 255, 255, 255, 255,
   /* 8 */  255, 255, 255, 255, 255, 255, 255, 255,
   /* 16 */ 255, 255, 255, 255, 255, 255, 255, 255,
   /* 24 */ 255, 255, 255, 255, 255, 255, 255, 255,
   /* 32 */ 255, 255, 255, 255, 255, 255, 255, 255,
   /* 40 */ 255, 255, 255,
   62 /* + */,
   255, 255, 255,
@@ -262,16 +264,17 @@ static const uint8_t kBase64DecodeTable[
   /* 72 */ 7, 8, 9, 10, 11, 12, 13, 14,
   /* 80 */ 15, 16, 17, 18, 19, 20, 21, 22,
   /* 88 */ 23, 24, 25, 255, 255, 255, 255, 255,
   /* 96 */ 255, /* a - z */ 26, 27, 28, 29, 30, 31, 32,
   /* 104 */ 33, 34, 35, 36, 37, 38, 39, 40,
   /* 112 */ 41, 42, 43, 44, 45, 46, 47, 48,
   /* 120 */ 49, 50, 51, 255, 255, 255, 255, 255,
 };
+// clang-format on
 
 template<typename T>
 MOZ_MUST_USE bool
 Base64CharToValue(T aChar, uint8_t* aValue)
 {
   static const size_t mask = 0x7f;
   static_assert((mask + 1) == sizeof(kBase64DecodeTable)/sizeof(kBase64DecodeTable[0]),
                 "wrong mask");
@@ -286,16 +289,17 @@ Base64CharToValue(T aChar, uint8_t* aVal
 }
 
 static const char kBase64URLAlphabet[] =
   "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
 
 // Maps an encoded character to a value in the Base64 URL alphabet, per
 // RFC 4648, Table 2. Invalid input characters map to UINT8_MAX.
 static const uint8_t kBase64URLDecodeTable[] = {
+// clang-format off
   255, 255, 255, 255, 255, 255, 255, 255,
   255, 255, 255, 255, 255, 255, 255, 255,
   255, 255, 255, 255, 255, 255, 255, 255,
   255, 255, 255, 255, 255, 255, 255, 255,
   255, 255, 255, 255, 255, 255, 255, 255,
   255, 255, 255, 255, 255,
   62 /* - */,
   255, 255,
@@ -305,16 +309,17 @@ static const uint8_t kBase64URLDecodeTab
   16, 17, 18, 19, 20, 21, 22, 23, 24, 25, /* A - Z */
   255, 255, 255, 255,
   63 /* _ */,
   255,
   26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
   42, 43, 44, 45, 46, 47, 48, 49, 50, 51, /* a - z */
   255, 255, 255, 255,
 };
+// clang-format on
 
 bool
 Base64URLCharToValue(char aChar, uint8_t* aValue) {
   uint8_t index = static_cast<uint8_t>(aChar);
   *aValue = kBase64URLDecodeTable[index & 0x7f];
   return (*aValue != 255) && !(index & ~0x7f);
 }