1 Index: sope-gdl1/PostgreSQL/PostgreSQL72Channel.m
2 ===================================================================
3 --- sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (révision 1546)
4 +++ sope-gdl1/PostgreSQL/PostgreSQL72Channel.m (copie de travail)
9 +/* GCSEOAdaptorChannel protocol */
10 +static NSString *sqlFolderFormat = (@"CREATE TABLE %@ (\n" \
11 + @" c_name VARCHAR (256) NOT NULL,\n"
12 + @" c_content VARCHAR (100000) NOT NULL,\n"
13 + @" c_creationdate INT4 NOT NULL,\n"
14 + @" c_lastmodified INT4 NOT NULL,\n"
15 + @" c_version INT4 NOT NULL,\n"
16 + @" c_deleted INT4 NULL\n"
18 +static NSString *sqlFolderACLFormat = (@"CREATE TABLE %@ (\n" \
19 + @" c_uid VARCHAR (256) NOT NULL,\n"
20 + @" c_object VARCHAR (256) NOT NULL,\n"
21 + @" c_role VARCHAR (80) NOT NULL\n"
24 +- (NSException *) createGCSFolderTableWithName: (NSString *) tableName
28 + sql = [NSString stringWithFormat: sqlFolderFormat, tableName];
30 + return [self evaluateExpressionX: sql];
33 +- (NSException *) createGCSFolderACLTableWithName: (NSString *) tableName
37 + sql = [NSString stringWithFormat: sqlFolderACLFormat, tableName];
39 + return [self evaluateExpressionX: sql];
42 @end /* PostgreSQL72Channel */
44 @implementation PostgreSQL72Channel(PrimaryKeyGeneration)
45 Index: sope-gdl1/Oracle8/GNUmakefile
46 ===================================================================
47 --- sope-gdl1/Oracle8/GNUmakefile (révision 1546)
48 +++ sope-gdl1/Oracle8/GNUmakefile (copie de travail)
51 ORACLE_VERSION=10.2.0.3
52 #ORACLE_VERSION=11.1.0.1
53 -ADDITIONAL_INCLUDE_DIRS += -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client
54 +ADDITIONAL_INCLUDE_DIRS += -I../../sope-core -I../../sope-core/NGExtensions -I../GDLAccess -I.. -I/usr/include/oracle/$(ORACLE_VERSION)/client
56 +local_arch = $(subst 64,,$(shell uname -m))
58 +ifeq ($(local_arch),ppc)
59 +PPC_LDFLAGS=-L/opt/ibmcmp/lib -libmc++
64 ifneq ($(frameworks),yes)
65 -Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl
66 -otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -lGDLAccess -lEOControl
67 +common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -L../GDLAccess/obj -lGDLAccess -L../../sope-core/EOControl/obj -lEOControl $(PPC_LDFLAGS)
69 -Oracle8_BUNDLE_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl
70 -otest_TOOL_LIBS += -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl
71 +common_LIBS = -L/usr/lib/oracle/$(ORACLE_VERSION)/client/lib/ -locci -lociei -lclntsh -lnnz10 -framework GDLAccess -framework EOControl $(PPC_LDFLAGS)
73 +Oracle8_BUNDLE_LIBS += $(common_LIBS)
74 +otest_TOOL_LIBS += $(common_LIBS)
78 Index: sope-gdl1/Oracle8/OracleAdaptorChannel.m
79 ===================================================================
80 --- sope-gdl1/Oracle8/OracleAdaptorChannel.m (révision 1546)
81 +++ sope-gdl1/Oracle8/OracleAdaptorChannel.m (copie de travail)
85 info = [[_row_buffer objectAtIndex: c] pointerValue];
86 - [_row_buffer removeObjectAtIndex: c];
88 // We free our LOB object. If it fails, it likely mean it isn't a LOB
89 // so we just free the value instead.
90 - if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS)
96 + if (OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB) != OCI_SUCCESS)
101 + [_row_buffer removeObjectAtIndex: c];
104 OCIHandleFree(_current_stm, OCI_HTYPE_STMT);
107 @implementation OracleAdaptorChannel
112 + if (OCITerminate(OCI_DEFAULT))
113 + NSLog(@"FAILED: OCITerminate()");
115 + NSLog(@"Oracle8: environment shut down");
120 + // We Initialize the OCI process environment.
121 + if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0,
122 + (dvoid * (*)(dvoid *, size_t)) 0,
123 + (dvoid * (*)(dvoid *, dvoid *, size_t))0,
124 + (void (*)(dvoid *, dvoid *)) 0 ))
125 + NSLog(@"FAILED: OCIInitialize()");
128 + NSLog(@"Oracle8: environment initialized");
129 + atexit(DBTerminate);
133 - (id) initWithAdaptorContext: (EOAdaptorContext *) theAdaptorContext
135 if ((self = [super initWithAdaptorContext: theAdaptorContext]))
136 @@ -134,10 +161,14 @@
137 NSLog(@"FAILED: OCILogoff()");
140 - if (OCITerminate(OCI_DEFAULT))
142 - NSLog(@"FAILED: OCITerminate()");
145 + OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX);
146 + OCIHandleFree(_oci_err, OCI_HTYPE_ERROR);
147 + // OCIHandleFree(_oci_env, OCI_HTYPE_ENV);
149 + _oci_ctx = (OCISvcCtx *)0;
150 + _oci_err = (OCIError *)0;
151 + _oci_env = (OCIEnv *)0;
158 RELEASE(_resultSetProperties);
160 - OCIHandleFree(_oci_ctx, OCI_HTYPE_SVCCTX);
161 - OCIHandleFree(_oci_err, OCI_HTYPE_ERROR);
162 - OCIHandleFree(_oci_env, OCI_HTYPE_ENV);
171 - // We Initialize the OCI process environment.
172 - if (OCIInitialize((ub4)OCI_DEFAULT, (dvoid *)0,
173 - (dvoid * (*)(dvoid *, size_t)) 0,
174 - (dvoid * (*)(dvoid *, dvoid *, size_t))0,
175 - (void (*)(dvoid *, dvoid *)) 0 ))
177 - NSLog(@"FAILED: OCIInitialize()");
182 if (OCIEnvInit((OCIEnv **)&_oci_env, (ub4)OCI_DEFAULT, (size_t)0, (dvoid **)0))
184 NSLog(@"FAILED: OCIEnvInit()");
185 Index: sope-gdl1/Oracle8/OracleAdaptorChannelController.m
186 ===================================================================
187 --- sope-gdl1/Oracle8/OracleAdaptorChannelController.m (révision 1546)
188 +++ sope-gdl1/Oracle8/OracleAdaptorChannelController.m (copie de travail)
190 OCILobFreeTemporary([theChannel serviceContext], [theChannel errorHandle], info->value);
191 OCIDescriptorFree((dvoid *)info->value, (ub4)OCI_DTYPE_LOB);
195 + [theColumns release];
197 OCIHandleFree(theStatement, OCI_HTYPE_STMT);
199 Index: sope-mime/NGImap4/NGImap4Connection.m
200 ===================================================================
201 --- sope-mime/NGImap4/NGImap4Connection.m (révision 1546)
202 +++ sope-mime/NGImap4/NGImap4Connection.m (copie de travail)
205 if (debugCache) [self logWithFormat:@" no folders cached yet .."];
207 - result = [[self client] list:(onlyFetchInbox ? @"INBOX" : @"*")
208 + result = [[self client] list:(onlyFetchInbox ? @"INBOX" : @"")
210 if (![[result valueForKey:@"result"] boolValue]) {
211 [self errorWithFormat:@"Could not list mailbox hierarchy!"];
212 Index: sope-mime/NGImap4/NGImap4ResponseNormalizer.m
213 ===================================================================
214 --- sope-mime/NGImap4/NGImap4ResponseNormalizer.m (révision 1546)
215 +++ sope-mime/NGImap4/NGImap4ResponseNormalizer.m (copie de travail)
216 @@ -648,14 +648,13 @@
217 enumerator = [_flags objectEnumerator];
219 while ((obj = [enumerator nextObject])) {
220 - if (![obj isNotEmpty])
223 - if (![[obj substringToIndex:1] isEqualToString:@"\\"])
226 - objs[cnt] = [obj substringFromIndex:1];
228 + if ([obj isNotEmpty]) {
229 + if ([obj hasPrefix:@"\\"])
230 + objs[cnt] = [obj substringFromIndex:1];
236 result = [NSArray arrayWithObjects:objs count:cnt];
237 if (objs) free(objs);
238 Index: sope-mime/NGImap4/NGImap4ResponseParser.m
239 ===================================================================
240 --- sope-mime/NGImap4/NGImap4ResponseParser.m (révision 1546)
241 +++ sope-mime/NGImap4/NGImap4ResponseParser.m (copie de travail)
243 static NSDictionary *_parseMultipartBody(NGImap4ResponseParser *self,
244 BOOL isBodyStructure);
246 +static NSArray *_parseLanguages();
248 static NSString *_parseBodyString(NGImap4ResponseParser *self,
249 BOOL _convertString);
250 static NSString *_parseBodyDecodeString(NGImap4ResponseParser *self,
252 static NSNumber *_parseUnsigned(NGImap4ResponseParser *self);
253 static NSString *_parseUntil(NGImap4ResponseParser *self, char _c);
254 static NSString *_parseUntil2(NGImap4ResponseParser *self, char _c1, char _c2);
255 +static BOOL _endsWithCQuote(NSString *_string);
257 static __inline__ NSException *_consumeIfMatch
258 (NGImap4ResponseParser *self, unsigned char _m);
259 @@ -649,12 +652,31 @@
262 - (NSString *)_parseQuotedString {
263 + NSMutableString *quotedString;
264 + NSString *tmpString;
267 /* parse a quoted string, eg '"' */
268 if (_la(self, 0) == '"') {
270 - return _parseUntil(self, '"');
271 + quotedString = [NSMutableString string];
274 + tmpString = _parseUntil(self, '"');
275 + [quotedString appendString: tmpString];
276 + if(_endsWithCQuote(tmpString)) {
277 + [quotedString deleteSuffix: @"\\"];
278 + [quotedString appendString: @"\""];
287 + quotedString = nil;
289 + return quotedString;
291 - (void)_consumeOptionalSpace {
292 if (_la(self, 0) == ' ') _consume(self, 1);
293 @@ -1185,7 +1207,7 @@
294 route = [self _parseQuotedStringOrNIL]; [self _consumeOptionalSpace];
295 mailbox = [self _parseQuotedStringOrNIL]; [self _consumeOptionalSpace];
296 host = [self _parseQuotedStringOrNIL]; [self _consumeOptionalSpace];
299 if (_la(self, 0) != ')') {
300 [self logWithFormat:@"WARNING: IMAP4 envelope "
301 @"address not properly closed (c0=%c,c1=%c): %@",
302 @@ -1197,6 +1219,7 @@
303 address = [[NGImap4EnvelopeAddress alloc] initWithPersonalName:pname
304 sourceRoute:route mailbox:mailbox
310 @@ -1627,6 +1650,29 @@
311 return _parseBodyDecodeString(self, _convertString, NO /* no decode */);
314 +static NSArray *_parseLanguages(NGImap4ResponseParser *self) {
315 + NSMutableArray *languages;
316 + NSString *language;
318 + languages = [NSMutableArray array];
319 + if (_la(self, 0) == '(') {
320 + while (_la(self, 0) != ')') {
322 + language = _parseBodyString(self, YES);
323 + if ([language length])
324 + [languages addObject: language];
329 + language = _parseBodyString(self, YES);
330 + if ([language length])
331 + [languages addObject: language];
337 static NSDictionary *_parseBodyParameterList(NGImap4ResponseParser *self)
339 NSMutableDictionary *list;
340 @@ -1734,10 +1780,11 @@
341 *encoding, *bodysize;
342 NSDictionary *parameterList;
343 NSMutableDictionary *dict;
344 + NSArray *languages;
346 type = [_parseBodyString(self, YES) lowercaseString];
347 _consumeIfMatch(self, ' ');
348 - subtype = _parseBodyString(self, YES);
349 + subtype = [_parseBodyString(self, YES) lowercaseString];
350 _consumeIfMatch(self, ' ');
351 parameterList = _parseBodyParameterList(self);
352 _consumeIfMatch(self, ' ');
353 @@ -1762,7 +1809,8 @@
354 _consumeIfMatch(self, ' ');
355 [dict setObject:_parseBodyString(self, YES) forKey:@"lines"];
357 - else if ([type isEqualToString:@"message"]) {
358 + else if ([type isEqualToString:@"message"]
359 + && [subtype isEqualToString:@"rfc822"]) {
360 if (_la(self, 0) != ')') {
361 _consumeIfMatch(self, ' ');
362 _consumeIfMatch(self, '(');
363 @@ -1805,14 +1853,9 @@
364 forKey: @"disposition"];
365 if (_la(self, 0) != ')') {
367 - if (_la(self, 0) == '(') {
368 - [dict setObject: _parseBodyParameterList(self)
369 - forKey: @"language"];
372 - [dict setObject: _parseBodyString(self, YES)
373 - forKey: @"language"];
375 + languages = _parseLanguages(self);
376 + if ([languages count])
377 + [dict setObject: languages forKey: @"languages"];
378 if (_la(self, 0) != ')') {
380 [dict setObject: _parseBodyString(self, YES)
381 @@ -1829,6 +1872,7 @@
382 static NSDictionary *_parseMultipartBody(NGImap4ResponseParser *self,
383 BOOL isBodyStructure) {
384 NSMutableArray *parts;
385 + NSArray *languages;
387 NSMutableDictionary *dict;
389 @@ -1854,14 +1898,9 @@
390 forKey: @"disposition"];
391 if (_la(self, 0) != ')') {
393 - if (_la(self, 0) == '(') {
394 - [dict setObject: _parseBodyParameterList(self)
395 - forKey: @"language"];
398 - [dict setObject: _parseBodyString(self, YES)
399 - forKey: @"language"];
401 + languages = _parseLanguages(self);
402 + if ([languages count])
403 + [dict setObject: languages forKey: @"languages"];
404 if (_la(self, 0) != ')') {
406 [dict setObject: _parseBodyString(self, YES)
407 @@ -2170,6 +2209,21 @@
411 +static BOOL _endsWithCQuote(NSString *_string){
412 + unsigned int quoteSlashes;
416 + pos = [_string length] - 1;
418 + && [_string characterAtIndex: pos] == '\\') {
423 + return ((quoteSlashes % 2) == 1);
426 - (NSException *)exceptionForFailedMatch:(unsigned char)_match
427 got:(unsigned char)_avail
429 Index: sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m
430 ===================================================================
431 --- sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m (révision 1546)
432 +++ sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m (copie de travail)
433 @@ -285,24 +285,16 @@
434 - (id)parseValue:(id)_data ofHeaderField:(NSString *)_field {
436 NSCalendarDate *date = nil;
437 - unsigned char buf[256];
438 - unsigned char *bytes = buf, *pe;
439 + unsigned char *bytes, *pe;
441 NSTimeZone *tz = nil;
442 char dayOfMonth, monthOfYear, hour, minute, second;
446 - if ((length = [_data cStringLength]) > 254) {
447 - [self logWithFormat:
448 - @"header field value to large for date parsing: '%@'(%i)",
453 - [_data getCString:(char *)buf maxLength:length];
454 - buf[length] = '\0';
457 + length = [_data length];
458 + bytes = [_data cStringUsingEncoding: NSASCIIStringEncoding];
460 /* remove leading chars (skip to first digit, the day of the month) */
461 while (length > 0 && (!isdigit(*bytes))) {
463 Index: sope-mime/NGMime/NGMimeBodyPart.m
464 ===================================================================
465 --- sope-mime/NGMime/NGMimeBodyPart.m (révision 1546)
466 +++ sope-mime/NGMime/NGMimeBodyPart.m (copie de travail)
471 -static NGMimeType *defaultType = nil;
473 -+ (void)initialize {
474 - static BOOL isInitialized = NO;
475 - if (!isInitialized) {
476 - isInitialized = YES;
479 - [[NGMimeType mimeType:@"text/plain; charset=us-ascii"] retain];
483 + (id)bodyPartWithHeader:(NGHashMap *)_header {
484 return [[[self alloc] initWithHeader:_header] autorelease];
486 @@ -156,13 +144,12 @@
488 Fields = (NGMimeHeaderNames *)[NGMimePartParser headerFieldNames];
491 type = [self->header objectForKey:Fields->contentType];
493 if (![type isKindOfClass:[NGMimeType class]])
494 type = [NGMimeType mimeType:[type stringValue]];
496 - return (type != nil ? type : (id)defaultType);
500 - (NSString *)contentId {
501 Index: sope-mime/NGMime/NGMimeBodyParser.m
502 ===================================================================
503 --- sope-mime/NGMime/NGMimeBodyParser.m (révision 1546)
504 +++ sope-mime/NGMime/NGMimeBodyParser.m (copie de travail)
506 if (_data == nil) return nil;
508 ctype = [_part contentType];
511 + && [_d respondsToSelector: @selector(parser:contentTypeOfPart:)])
512 + ctype = [_d parser: self contentTypeOfPart: _part];
514 if (![ctype isKindOfClass:[NGMimeType class]])
515 ctype = [NGMimeType mimeType:[ctype stringValue]];
517 Index: sope-mime/NGMime/NGMimePartParser.h
518 ===================================================================
519 --- sope-mime/NGMime/NGMimePartParser.h (révision 1546)
520 +++ sope-mime/NGMime/NGMimePartParser.h (copie de travail)
522 BOOL parserParseRawBodyDataOfPart:1;
523 BOOL parserBodyParserForPart:1;
524 BOOL parserDecodeBodyOfPart:1;
525 + BOOL parserContentTypeOfPart:1;
526 } delegateRespondsTo;
530 - (id<NGMimeBodyParser>)parser:(NGMimePartParser *)_parser
531 bodyParserForPart:(id<NGMimePart>)_part;
533 +- (NGMimeType *)parser:(id)_parser
534 + contentTypeOfPart:(id<NGMimePart>)_part;
536 @end /* NSObject(NGMimePartParserDelegate) */
538 @interface NSObject(NGMimePartParser)
539 Index: sope-mime/NGMime/NGMimePartParser.m
540 ===================================================================
541 --- sope-mime/NGMime/NGMimePartParser.m (révision 1546)
542 +++ sope-mime/NGMime/NGMimePartParser.m (copie de travail)
543 @@ -1091,7 +1091,10 @@
544 id<NGMimeBodyParser> bodyParser = nil;
546 ctype = [_p contentType];
549 + && self->delegateRespondsTo.parserContentTypeOfPart)
550 + ctype = [self->delegate parser: self contentTypeOfPart: _p];
552 contentType = ([ctype isKindOfClass:[NGMimeType class]])
554 : [NGMimeType mimeType:[ctype stringValue]];
555 Index: sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m
556 ===================================================================
557 --- sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m (révision 1546)
558 +++ sope-core/NGExtensions/FdExt.subproj/NSString+Encoding.m (copie de travail)
565 #include <NGExtensions/NSString+Encoding.h>
566 #include <NGExtensions/NSObject+Logs.h>
570 #else /* ! NeXT_Foundation_LIBRARY */
573 @implementation NSString(Encoding)
575 #if GNUSTEP_BASE_LIBRARY
576 @@ -192,17 +193,17 @@
578 memcpy(outbuf, _src, _srcLen);
585 fromEncode = [_fromEncode cString];
586 toEncode = [_toEncode cString];
589 type = iconv_open(toEncode, fromEncode);
594 if ((type == (iconv_t)-1)) {
595 [self logWithFormat:@"%s: Could not handle iconv encoding. FromEncoding:%@"
596 @" to encoding:%@", __PRETTY_FUNCTION__, _fromEncode, _toEncode];
597 @@ -228,25 +229,25 @@
599 else if (errno == EINVAL) {
600 [self logWithFormat:@"Got incomplete multibyte sequence. ToEncode: %@"
601 - @" FromEncode: %@", _toEncode, _fromEncode];
602 + @" FromEncode: %@", _toEncode, _fromEncode];
604 [self logWithFormat:@"ByteSequence:\n%s\n", _src];
608 else if (errno == E2BIG) {
610 - @"Got to small outputbuffer (inbytesleft=%d, outbytesleft=%d, "
611 - @"outlen=%d). ToEncode: %@ FromEncode: %@",
612 - inbytesleft, outbytesleft, outlen,
613 - _toEncode, _fromEncode];
614 + @"Got to small outputbuffer (inbytesleft=%d, outbytesleft=%d, "
615 + @"outlen=%d). ToEncode: %@ FromEncode: %@",
616 + inbytesleft, outbytesleft, outlen,
617 + _toEncode, _fromEncode];
619 [self logWithFormat:@"ByteSequence:\n%s\n", _src];
622 goto CLEAR_AND_RETURN;
625 [self logWithFormat:@"Got unexpected error. ToEncode: %@"
626 - @" FromEncode: %@", _toEncode, _fromEncode];
627 + @" FromEncode: %@", _toEncode, _fromEncode];
628 goto CLEAR_AND_RETURN;
631 @@ -255,45 +256,224 @@
637 *outLen_ = outlen - outbytesleft;
649 free(outbuf); outbuf = NULL;
654 -+ (NSString *)stringWithData:(NSData *)_data
655 - usingEncodingNamed:(NSString *)_encoding
656 ++ (int) encodingForCharset: (NSString *) theCharset
657 + convertToNSStringEncoding: (BOOL) shouldConvert
660 - unsigned len, inbufLen;
662 + // We define some aliases for the string encoding.
663 + static struct { NSString *name; int encoding; BOOL fromCoreFoundation; } encodings[] = {
664 + {@"ascii" ,NSASCIIStringEncoding ,NO},
665 + {@"us-ascii" ,NSASCIIStringEncoding ,NO},
666 + {@"default" ,NSASCIIStringEncoding ,NO}, // Ah... spammers.
667 + {@"utf-8" ,NSUTF8StringEncoding ,NO},
668 + {@"iso-8859-1" ,NSISOLatin1StringEncoding ,NO},
669 + {@"x-user-defined",NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Outlook.
670 + {@"unknown" ,NSISOLatin1StringEncoding ,NO}, // Once more, blame Outlook.
671 + {@"x-unknown" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Pine 4.21.
672 + {@"unknown-8bit" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Mutt/1.3.28i
673 + {@"0" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in QUALCOMM Windows Eudora Version 6.0.1.1
674 + {@"" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Ximian Evolution
675 + {@"iso8859_1" ,NSISOLatin1StringEncoding ,NO}, // To prevent a lame bug in Openwave WebEngine
676 + {@"iso-8859-2" ,NSISOLatin2StringEncoding ,NO},
678 + {@"iso-8859-3" ,NSISOLatin3StringEncoding ,NO},
679 + {@"iso-8859-4" ,NSISOLatin4StringEncoding ,NO},
680 + {@"iso-8859-5" ,NSISOCyrillicStringEncoding ,NO},
681 + {@"iso-8859-6" ,NSISOArabicStringEncoding ,NO},
682 + {@"iso-8859-7" ,NSISOGreekStringEncoding ,NO},
683 + {@"iso-8859-8" ,NSISOHebrewStringEncoding ,NO},
684 + {@"iso-8859-9" ,NSISOLatin5StringEncoding ,NO},
685 + {@"iso-8859-10" ,NSISOLatin6StringEncoding ,NO},
686 + {@"iso-8859-11" ,NSISOThaiStringEncoding ,NO},
687 + {@"iso-8859-13" ,NSISOLatin7StringEncoding ,NO},
688 + {@"iso-8859-14" ,NSISOLatin8StringEncoding ,NO},
689 + {@"iso-8859-15" ,NSISOLatin9StringEncoding ,NO},
690 + {@"koi8-r" ,NSKOI8RStringEncoding ,NO},
691 + {@"big5" ,NSBIG5StringEncoding ,NO},
692 + {@"gb2312" ,NSGB2312StringEncoding ,NO},
693 + {@"utf-7" ,NSUTF7StringEncoding ,NO},
694 + {@"unicode-1-1-utf-7", NSUTF7StringEncoding ,NO}, // To prever a bug (sort of) in MS Hotmail
696 + {@"windows-1250" ,NSWindowsCP1250StringEncoding ,NO},
697 + {@"windows-1251" ,NSWindowsCP1251StringEncoding ,NO},
698 + {@"cyrillic (windows-1251)", NSWindowsCP1251StringEncoding ,NO}, // To prevent a bug in MS Hotmail
699 + {@"windows-1252" ,NSWindowsCP1252StringEncoding ,NO},
700 + {@"windows-1253" ,NSWindowsCP1253StringEncoding ,NO},
701 + {@"windows-1254" ,NSWindowsCP1254StringEncoding ,NO},
702 + {@"iso-2022-jp" ,NSISO2022JPStringEncoding ,NO},
703 + {@"euc-jp" ,NSJapaneseEUCStringEncoding ,NO},
709 - if (![_encoding length])
711 + name = [theCharset lowercaseString];
713 - inbufLen = [_data length];
714 - inbuf = calloc(sizeof(char), inbufLen + 4);
715 - [_data getBytes:inbuf];
716 + for (i = 0; i < sizeof(encodings)/sizeof(encodings[0]); i++)
718 + if ([name isEqualToString: encodings[i].name])
720 + int enc = encodings[i].encoding;
721 + // Under OS X, we use CoreFoundation if necessary to convert the encoding
722 + // to a NSString encoding.
724 + if (encodings[i].fromCoreFoundation)
728 + return CFStringConvertEncodingToNSStringEncoding(enc);
737 + if (!shouldConvert)
739 + return CFStringConvertNSStringEncodingToEncoding(enc);
753 - res = iconv_wrapper(self, inbuf, inbufLen, _encoding, unicharEncoding, &len);
755 - result = [[NSString alloc] initWithCharacters:res length:(len / 2)];
756 - free(res); res = NULL;
758 - if (inbuf) free(inbuf); inbuf = NULL;
759 - return [result autorelease];
761 + // Last resort: try using CoreFoundation...
762 + CFStringEncoding enc;
764 + enc = CFStringConvertIANACharSetNameToEncoding((CFStringRef)name);
765 + if (kCFStringEncodingInvalidId != enc)
769 + return CFStringConvertEncodingToNSStringEncoding(enc);
781 ++ (int) encodingForCharset: (NSString *) theCharset
783 + return [self encodingForCharset: theCharset convertToNSStringEncoding: YES];
786 ++ (NSString *) stringWithData: (NSData *) theData
787 + usingEncodingNamed: (NSString *) theCharset
791 + if (theData == nil)
797 + encoding = [NSString encodingForCharset: theCharset
798 + convertToNSStringEncoding: NO];
800 + encoding = [NSString encodingForCharset: theCharset];
803 + if (encoding == -1)
806 + const char *i_bytes;
809 + size_t i_length, o_length;
810 + int total_length, ret;
813 + // Instead of calling cString directly on theCharset, we first try
814 + // to obtain the ASCII string of the data object.
820 + conv = iconv_open("UTF-8", [[theCharset uppercaseString] cStringUsingEncoding: NSISOLatin1StringEncoding]);
824 + // Let's assume we got US-ASCII here.
825 + return AUTORELEASE([[NSString alloc] initWithData: theData encoding: NSASCIIStringEncoding]);
828 + i_bytes = [theData bytes];
829 + i_length = [theData length];
831 + total_length = o_length = sizeof(unichar)*i_length;
832 + o_bytes = (char *)malloc(o_length);
834 + if (o_bytes == NULL) return nil;
836 + while (i_length > 0)
838 + ret = iconv(conv, (char **)&i_bytes, &i_length, &o_bytes, &o_length);
840 + if (ret == (size_t)-1)
844 + total_length = total_length - o_length;
845 + o_bytes -= total_length;
851 + total_length = total_length - o_length;
852 + o_bytes -= total_length;
854 + // If we haven't used all our allocated buffer, we shrink it.
857 + o_bytes = realloc(o_bytes, total_length);
860 + aString = [[NSString alloc] initWithData: [NSData dataWithBytesNoCopy: o_bytes
861 + length: total_length]
862 + encoding: NSUTF8StringEncoding];
865 + return AUTORELEASE(aString);
869 + return AUTORELEASE((NSString *)CFStringCreateFromExternalRepresentation(NULL, (CFDataRef)theData, encoding));
871 + return AUTORELEASE([[NSString alloc] initWithData: theData encoding: encoding]);
875 - (NSData *)dataUsingEncodingNamed:(NSString *)_encoding {
878 Index: sope-core/NGExtensions/ChangeLog
879 ===================================================================
880 --- sope-core/NGExtensions/ChangeLog (révision 1546)
881 +++ sope-core/NGExtensions/ChangeLog (copie de travail)
883 +2007-11-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
885 + * FdExt.subproj/NSString+Encoding.m: replaced the code of
886 + stringWithData:usingEncodingNamed: with the code from
887 + Pantomime/NSString+Extensions.m/stringWithData:charset:, which in
888 + turn was adapted to take the same argument types.
890 2007-07-31 Marcus Mueller <znek@mulle-kybernetik.com>
892 * FdExt.subproj/NSMethodSignature+misc.m: added warning and bogus
893 Index: sope-appserver/NGObjWeb/GNUmakefile.postamble
894 ===================================================================
895 --- sope-appserver/NGObjWeb/GNUmakefile.postamble (révision 1546)
896 +++ sope-appserver/NGObjWeb/GNUmakefile.postamble (copie de travail)
902 +after-install :: $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/Additional/ngobjweb.make
904 +ifneq ($(GNUSTEP_MAKE_VERSION),1.3.0)
905 +after-install :: $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/woapp.make $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/wobundle.make
908 +$(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/Additional/ngobjweb.make: ngobjweb.make
909 $(MKDIRS) $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/Additional/
910 $(INSTALL_DATA) ngobjweb.make $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/Additional/ngobjweb.make
912 -ifneq ($(GNUSTEP_MAKE_VERSION),1.3.0)
914 +$(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/woapp.make: woapp-gs.make
915 $(INSTALL_DATA) woapp-gs.make \
916 $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/woapp.make
918 +$(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/wobundle.make: wobundle-gs.make
919 $(INSTALL_DATA) wobundle-gs.make \
920 $(INSTALL_ROOT_DIR)/$(GNUSTEP_MAKEFILES)/wobundle.make
922 Index: sope-appserver/NGObjWeb/WOContext.m
923 ===================================================================
924 --- sope-appserver/NGObjWeb/WOContext.m (révision 1546)
925 +++ sope-appserver/NGObjWeb/WOContext.m (copie de travail)
927 static BOOL testNSURLs = NO;
928 static BOOL newCURLStyle = NO;
929 static NSString *WOApplicationSuffix = nil;
930 +static NSURL *redirectURL = nil;
933 static BOOL didInit = NO;
941 debugCursor = [ud boolForKey:@"WODebugCursor"] ? 1 : 0;
942 debugComponentAwake = [ud boolForKey:@"WODebugComponentAwake"];
943 WOApplicationSuffix = [[ud stringForKey:@"WOApplicationSuffix"] copy];
944 + url = [ud stringForKey:@"WOApplicationRedirectURL"];
946 + redirectURL = [NSURL URLWithString: url];
949 + (id)contextWithRequest:(WORequest *)_r {
955 + // Use URL from user defaults (WOApplicationRedirectURL)
956 + return redirectURL;
959 if ((serverURL = [rq headerForKey:@"x-webobjects-server-url"]) == nil) {
960 if ((host = [rq headerForKey:@"host"]))
961 serverURL = [@"http://" stringByAppendingString:host];
962 Index: sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.m
963 ===================================================================
964 --- sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.m (révision 1546)
965 +++ sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.m (copie de travail)
971 + if ((self->isAbsolute = OWGetProperty(_config, @"absolute"))) {
977 self->rest = _config;
979 Index: sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m
980 ===================================================================
981 --- sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m (révision 1546)
982 +++ sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m (copie de travail)
984 WOAssociation *string;
985 WOAssociation *target;
986 WOAssociation *disabled;
987 + WOAssociation *isAbsolute;
993 if ((self = [super initWithName:_name hyperlinkInfo:_info template:_t])) {
994 self->href = _info->href;
995 + self->isAbsolute = _info->isAbsolute;
1000 // TODO: we need a binding to disable rewriting!
1003 + if ([[self->isAbsolute valueInContext:_ctx] boolValue] == YES)
1006 r = [_s rangeOfString:@":"];
1009 Index: sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.h
1010 ===================================================================
1011 --- sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.h (révision 1546)
1012 +++ sope-appserver/NGObjWeb/DynamicElements/WOHyperlinkInfo.h (copie de travail)
1014 WOAssociation *pageName;
1015 WOAssociation *actionClass;
1016 WOAssociation *directActionName;
1018 + WOAssociation *isAbsolute;
1022 /* 'ivar' associations */
1023 Index: sope-appserver/NGObjWeb/SoObjects/SoObject.m
1024 ===================================================================
1025 --- sope-appserver/NGObjWeb/SoObjects/SoObject.m (révision 1546)
1026 +++ sope-appserver/NGObjWeb/SoObjects/SoObject.m (copie de travail)
1028 static int debugLookup = -1;
1029 static int debugBaseURL = -1;
1030 static int useRelativeURLs = -1;
1031 +static int redirectInitted = -1;
1032 +static NSURL *redirectURL = nil;
1034 static void _initialize(void) {
1036 + NSUserDefaults *ud;
1038 + ud = [NSUserDefaults standardUserDefaults];
1040 if (debugLookup == -1) {
1041 - debugLookup = [[NSUserDefaults standardUserDefaults]
1042 - boolForKey:@"SoDebugKeyLookup"] ? 1 : 0;
1043 + debugLookup = [ud boolForKey:@"SoDebugKeyLookup"] ? 1 : 0;
1044 NSLog(@"Note(SoObject): SoDebugKeyLookup is enabled!");
1046 if (debugBaseURL == -1) {
1047 - debugBaseURL = [[NSUserDefaults standardUserDefaults]
1048 - boolForKey:@"SoDebugBaseURL"] ? 1 : 0;
1049 + debugBaseURL = [ud boolForKey:@"SoDebugBaseURL"] ? 1 : 0;
1050 NSLog(@"Note(SoObject): SoDebugBaseURL is enabled!");
1052 if (useRelativeURLs == -1) {
1053 - useRelativeURLs = [[NSUserDefaults standardUserDefaults]
1054 - boolForKey:@"WOUseRelativeURLs"] ?1:0;
1055 + useRelativeURLs = [ud boolForKey:@"WOUseRelativeURLs"] ?1:0;
1056 NSLog(@"Note(SoObject): relative base URLs are enabled.");
1058 + if (redirectInitted == -1) {
1059 + url = [ud stringForKey:@"WOApplicationRedirectURL"];
1060 + if ([url length]) {
1061 + redirectURL = [[NSURL alloc] initWithString: url];
1063 + redirectInitted = 1;
1068 @@ -318,56 +330,61 @@
1070 rq = [_ctx request];
1071 ms = [[NSMutableString alloc] initWithCapacity:128];
1073 + if (redirectURL) {
1074 + [ms appendString: [redirectURL absoluteString]];
1077 + if (!useRelativeURLs) {
1078 + port = [[rq headerForKey:@"x-webobjects-server-port"] intValue];
1080 - if (!useRelativeURLs) {
1081 - port = [[rq headerForKey:@"x-webobjects-server-port"] intValue];
1083 - /* this is actually a bug in Apache */
1085 - static BOOL didWarn = NO;
1087 - [self warnWithFormat:@"(%s:%i): got an empty port from Apache!",
1088 - __PRETTY_FUNCTION__, __LINE__];
1090 + /* this is actually a bug in Apache */
1092 + static BOOL didWarn = NO;
1094 + [self warnWithFormat:@"(%s:%i): got an empty port from Apache!",
1095 + __PRETTY_FUNCTION__, __LINE__];
1103 - if ((tmp = [rq headerForKey:@"host"]) != nil) {
1104 - /* check whether we have a host header with port */
1105 - if ([tmp rangeOfString:@":"].length == 0)
1108 - if (tmp != nil) { /* we have a host header with port */
1110 - [[rq headerForKey:@"x-webobjects-server-url"] hasPrefix:@"https"];
1111 - [ms appendString:isHTTPS ? @"https://" : @"http://"];
1112 - [ms appendString:tmp];
1114 - else if ((tmp = [rq headerForKey:@"x-webobjects-server-url"]) != nil) {
1115 - /* sometimes the URL is just wrong! (suggests port 80) */
1116 - if ([tmp hasSuffix:@":0"] && [tmp length] > 2) { // TODO: bad bad bad
1117 - [self warnWithFormat:@"%s: got incorrect URL from Apache: '%@'",
1118 - __PRETTY_FUNCTION__, tmp];
1119 - tmp = [tmp substringToIndex:([tmp length] - 2)];
1120 + if ((tmp = [rq headerForKey:@"host"]) != nil) {
1121 + /* check whether we have a host header with port */
1122 + if ([tmp rangeOfString:@":"].length == 0)
1125 - else if ([tmp hasSuffix:@":443"] && [tmp hasPrefix:@"http://"]) {
1126 - /* see OGo bug #1435, Debian Apache hack */
1127 - [self warnWithFormat:@"%s: got 'http' protocol but 443 port, "
1128 - @"assuming Debian/Apache bug (OGo #1435): '%@'",
1129 - __PRETTY_FUNCTION__, tmp];
1130 - tmp = [tmp substringWithRange:NSMakeRange(4, [tmp length] - 4 - 4)];
1131 - tmp = [@"https" stringByAppendingString:tmp];
1132 + if (tmp != nil) { /* we have a host header with port */
1134 + [[rq headerForKey:@"x-webobjects-server-url"] hasPrefix:@"https"];
1135 + [ms appendString:isHTTPS ? @"https://" : @"http://"];
1136 + [ms appendString:tmp];
1138 - [ms appendString:tmp];
1141 - // TODO: isHTTPS always no in this case?
1142 - [ms appendString:isHTTPS ? @"https://" : @"http://"];
1143 + else if ((tmp = [rq headerForKey:@"x-webobjects-server-url"]) != nil) {
1144 + /* sometimes the URL is just wrong! (suggests port 80) */
1145 + if ([tmp hasSuffix:@":0"] && [tmp length] > 2) { // TODO: bad bad bad
1146 + [self warnWithFormat:@"%s: got incorrect URL from Apache: '%@'",
1147 + __PRETTY_FUNCTION__, tmp];
1148 + tmp = [tmp substringToIndex:([tmp length] - 2)];
1150 + else if ([tmp hasSuffix:@":443"] && [tmp hasPrefix:@"http://"]) {
1151 + /* see OGo bug #1435, Debian Apache hack */
1152 + [self warnWithFormat:@"%s: got 'http' protocol but 443 port, "
1153 + @"assuming Debian/Apache bug (OGo #1435): '%@'",
1154 + __PRETTY_FUNCTION__, tmp];
1155 + tmp = [tmp substringWithRange:NSMakeRange(4, [tmp length] - 4 - 4)];
1156 + tmp = [@"https" stringByAppendingString:tmp];
1158 + [ms appendString:tmp];
1161 + // TODO: isHTTPS always no in this case?
1162 + [ms appendString:isHTTPS ? @"https://" : @"http://"];
1164 - [ms appendString:[rq headerForKey:@"x-webobjects-server-name"]];
1165 - if ((isHTTPS ? (port != 443) : (port != 80)) && port != 0)
1166 - [ms appendFormat:@":%i", port];
1167 + [ms appendString:[rq headerForKey:@"x-webobjects-server-name"]];
1168 + if ((isHTTPS ? (port != 443) : (port != 80)) && port != 0)
1169 + [ms appendFormat:@":%i", port];
1174 Index: sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m
1175 ===================================================================
1176 --- sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m (révision 1546)
1177 +++ sope-appserver/NGObjWeb/WOHttpAdaptor/WOHttpTransaction.m (copie de travail)
1179 #include <NGObjWeb/WOCookie.h>
1180 #include <NGExtensions/NSData+gzip.h>
1181 #include <NGHttp/NGHttp.h>
1182 +#include <NGMime/NGMimeType.h>
1186 @@ -1016,6 +1017,12 @@
1187 - (void)parser:(NGMimePartParser *)_parser didParseHeader:(NGHashMap *)_header {
1190 +- (NGMimeType *)parser:(id)_parser
1191 + contentTypeOfPart:(id<NGMimePart>)_part
1193 + return [NGMimeType mimeType: @"text/plain; charset=utf-8"];
1196 @end /* WOHttpAdaptor */
1198 @implementation WOCoreApplication(SimpleParserSelection)