This file is indexed.

/usr/include/GNUstep/NGMime/NGMimeUtilities.h is in libsope-dev 3.2.10-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 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
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
  Copyright (C) 2000-2005 SKYRIX Software AG

  This file is part of SOPE.

  SOPE is free software; you can redistribute it and/or modify it under
  the terms of the GNU Lesser General Public License as published by the
  Free Software Foundation; either version 2, or (at your option) any
  later version.

  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
  WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
  License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with SOPE; see the file COPYING.  If not, write to the
  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
  02111-1307, USA.
*/

#ifndef __NGMime_NGMimeUtilities_H__
#define __NGMime_NGMimeUtilities_H__

#import <Foundation/Foundation.h>
#import <NGExtensions/NGExtensions.h>
#include <NGMime/NGMimeDecls.h>

// ******************** RFC 822 ********************

static inline BOOL isRfc822_SpecialByte(unsigned char _byte) {
  switch (_byte) {
  case '(': case ')': case '<': case '>': case '@':
  case ',': case ';': case ':': case '"': case '\\':
  case '.': case '[': case ']':
    return YES;
  default:
    return NO;
  }
}

// single chars
NSDictionary *parseParameters(id self, NSString *_str, unichar *cstr);

static inline BOOL isRfc822_CR(unichar _byte) {
  return (_byte == 13);
}
static inline BOOL isRfc822_LF(unichar _byte) {
  return (_byte == 10);
}
static inline BOOL isRfc822_HTAB(unichar _byte) {
  return (_byte == 9);
}
static inline BOOL isRfc822_SPACE(unichar _byte) {
  return (_byte == 32);
}
static inline BOOL isRfc822_QUOTE(unichar _byte) {
  return (_byte == 34);
}

// ranges

static inline BOOL isRfc822_CHAR(unichar _byte) {
  return (_byte < 128);
}

static inline BOOL isRfc822_CTL(unichar _byte) {
  return (_byte < 32) || (_byte == 127);
}

static inline BOOL isRfc822_ALPHA(unichar _byte) {
  return (((_byte >= 65) && (_byte <= 90)) ||
          ((_byte >= 97) && (_byte <= 122)));
}

static inline BOOL isRfc822_DIGIT(unichar _byte) {
  return (_byte >= 48) && (_byte <= 57);
}

static inline BOOL isRfc822_LWSP(unichar _byte) {
  return (isRfc822_SPACE(_byte) || isRfc822_HTAB(_byte));
}


static inline BOOL isRfc822_FieldNameChar(unichar _byte) {
  return (isRfc822_CHAR(_byte) &&
          !(isRfc822_CTL(_byte) || isRfc822_SPACE(_byte) || (_byte == ':')));
}

static inline BOOL isRfc822_AtomChar(unichar _byte) {
  return (isRfc822_CHAR(_byte) &&
          !(isRfc822_SpecialByte(_byte) || isRfc822_SPACE(_byte) ||
            isRfc822_CTL(_byte)));
}

// ******************** MIME ***********************

static inline BOOL isMime_SpecialByte(unichar _byte) {
  switch (_byte) {
  case '(': case ')': case '<': case '>': case '@':
  case ',': case ';': case ':': case '"': case '\\':
  case '/': case '=': case '[': case ']': case '?':
    return YES;
  default:
    return NO;
  }
}

static inline BOOL isMime_TokenChar(unichar _byte) {
  return (isRfc822_CHAR(_byte) &&
          !(isRfc822_CTL(_byte) || isRfc822_SPACE(_byte) ||
            isMime_SpecialByte(_byte)));
}

static inline BOOL isMime_SafeChar(unichar _byte) {
  return ((_byte >= 33 && _byte <= 60) || (_byte >= 62 && _byte <= 126));
}

static inline BOOL isMime_ValidTypeXTokenChar(unichar _byte) {
  return !isRfc822_SPACE(_byte);
}

static inline BOOL isMime_ValidTypeAttributeChar(unichar _byte) {
  return isMime_TokenChar(_byte);
}

static inline NSData *_quotedPrintableEncoding(NSData *_data) {
  const char   *bytes;
  unsigned int length;
  NSData       *result = nil;  
  char         *des    = NULL;
  unsigned int desLen  = 0;
  unsigned     cnt;
  const char   *test;    
  BOOL         doEnc   = NO;

  bytes  = [_data bytes];
  length = [_data length];
  cnt    = length;
  test   = bytes;    
  
  for (cnt = length, test = bytes; cnt > 0; test++, cnt--) {
    if ((unsigned char)*test > 127) {
      doEnc = YES;
      break;
    }
  }
  if (!doEnc) 
    return _data;
  
  desLen = length *3;
  des = NGMallocAtomic(sizeof(char) * desLen + 2);
  
  desLen = NGEncodeQuotedPrintable(bytes, length, des, desLen);
  if ((int)desLen != -1) {
    result = [NSData dataWithBytesNoCopy:des length:desLen];
  }
  else {
    NSLog(@"WARNING(%s): An error occour during quoted-printable decoding",
          __PRETTY_FUNCTION__);
    if (des) NGFree(des);
    result = _data;
  }
  return result;
}

static inline NSData *_rfc2047Decoding(char _enc, const char *_bytes,
				       NSUInteger _length) 
{
  NSData *data = nil;

  if ((_enc == 'b') || (_enc == 'B')) { // use BASE64 decoding
    // TODO: improve efficiency (directly decode buffers w/o NSData)
    NSData *tmp;
    
    tmp = [[NSData alloc] initWithBytes:_bytes length:_length];
    data = [tmp dataByDecodingBase64];
    [tmp release]; tmp = nil;
  }
  else if ((_enc == 'q') || (_enc == 'Q')) { // use quoted-printable decoding
    char   *dest    = NULL;
    size_t destSize = 0;
    size_t resSize  = 0;

    destSize = _length;
    dest    = calloc(destSize + 2, sizeof(char));
    resSize = NGDecodeQuotedPrintable(_bytes, _length, dest, destSize);
    if ((int)resSize != -1) {
      data = [NSData dataWithBytesNoCopy:dest length:resSize];
    }
    else {
      NSLog(@"WARNING(%s): An error occour during quoted-printable decoding",
            __PRETTY_FUNCTION__);
      if (dest != NULL) free(dest); dest = NULL;
      data = [NSData dataWithBytes:_bytes length:_length];
    }
  }
  else {
    NSLog(@"WARNING(%s): unknown encoding type %c", __PRETTY_FUNCTION__, _enc);
    data = [NSData dataWithBytes:_bytes length:_length];
  }
  return data;
}

#endif /* __NGMime_NGMimeUtilities_H__ */