mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-02 09:31:07 +00:00
commit to match ChangeLog
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37055 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
49a2467fa3
commit
d21429e189
1 changed files with 24 additions and 40 deletions
|
@ -2921,17 +2921,26 @@ unfold(const unsigned char *src, const unsigned char *end, BOOL *folded)
|
||||||
{
|
{
|
||||||
/* Old web code tends to use latin1 (and RFCs say we
|
/* Old web code tends to use latin1 (and RFCs say we
|
||||||
* should use latin1 for headers). However newer systems
|
* should use latin1 for headers). However newer systems
|
||||||
* tend to use utf-8. We default to latin1 (as specified
|
* tend to use utf-8. We try any explicitly set encoding,
|
||||||
* in the RFCs) unless the encoding has been set to utf-8.
|
* then the modern utf-8, and finally fall back to latin1.
|
||||||
*/
|
*/
|
||||||
if (NSUTF8StringEncoding == _defaultEncoding)
|
if (NSUTF8StringEncoding != _defaultEncoding)
|
||||||
{
|
{
|
||||||
|
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
|
||||||
|
s = [s initWithBytes: beg
|
||||||
|
length: src - beg
|
||||||
|
encoding: _defaultEncoding];
|
||||||
|
}
|
||||||
|
if (nil == s)
|
||||||
|
{
|
||||||
|
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
|
||||||
s = [s initWithBytes: beg
|
s = [s initWithBytes: beg
|
||||||
length: src - beg
|
length: src - beg
|
||||||
encoding: NSUTF8StringEncoding];
|
encoding: NSUTF8StringEncoding];
|
||||||
}
|
}
|
||||||
else
|
if (nil == s)
|
||||||
{
|
{
|
||||||
|
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
|
||||||
s = [s initWithBytes: beg
|
s = [s initWithBytes: beg
|
||||||
length: src - beg
|
length: src - beg
|
||||||
encoding: NSISOLatin1StringEncoding];
|
encoding: NSISOLatin1StringEncoding];
|
||||||
|
@ -2942,43 +2951,18 @@ unfold(const unsigned char *src, const unsigned char *end, BOOL *folded)
|
||||||
s = [s initWithBytes: beg
|
s = [s initWithBytes: beg
|
||||||
length: src - beg
|
length: src - beg
|
||||||
encoding: NSASCIIStringEncoding];
|
encoding: NSASCIIStringEncoding];
|
||||||
}
|
if (nil == s && _defaultEncoding != NSASCIIStringEncoding)
|
||||||
if (nil == s && _defaultEncoding != NSASCIIStringEncoding)
|
{
|
||||||
{
|
/* The parser has been explicitly set to accept an
|
||||||
/* The parser has been explicitly set to accept an
|
* alternative coding ... Try the encoding we were
|
||||||
* alternative coding ... which means that this is
|
* given.
|
||||||
* not a MIME document. Trey the encoding we were
|
|
||||||
* given.
|
|
||||||
*/
|
|
||||||
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
|
|
||||||
s = [s initWithBytes: beg
|
|
||||||
length: src - beg
|
|
||||||
encoding: _defaultEncoding];
|
|
||||||
if (nil == s
|
|
||||||
&& _defaultEncoding != NSUTF8StringEncoding)
|
|
||||||
{
|
|
||||||
/* The specified encoding didn't work, but the case
|
|
||||||
* where we would not be parsing a MIME document is
|
|
||||||
* generally when parsing HTTP, and if the remote
|
|
||||||
* system (usually browser) is buggy and sending the
|
|
||||||
* wrong characterset it's almost certain to be UTF8
|
|
||||||
* or (for very old browsers) latin1.
|
|
||||||
*/
|
*/
|
||||||
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
|
s = [NSStringClass allocWithZone: NSDefaultMallocZone()];
|
||||||
s = [s initWithBytes: beg
|
s = [s initWithBytes: beg
|
||||||
length: src - beg
|
length: src - beg
|
||||||
encoding: NSUTF8StringEncoding];
|
encoding: _defaultEncoding];
|
||||||
if (nil == s
|
}
|
||||||
&& _defaultEncoding != NSISOLatin1StringEncoding)
|
}
|
||||||
{
|
|
||||||
s = [NSStringClass
|
|
||||||
allocWithZone: NSDefaultMallocZone()];
|
|
||||||
s = [s initWithBytes: beg
|
|
||||||
length: src - beg
|
|
||||||
encoding: NSISOLatin1StringEncoding];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (nil == s)
|
if (nil == s)
|
||||||
{
|
{
|
||||||
NSLog(@"Bad header ... illegal characters in %@",
|
NSLog(@"Bad header ... illegal characters in %@",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue