Fix detection of the charset in XML data

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@40090 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
thebeing 2016-09-19 15:56:51 +00:00
parent 59af31bfe9
commit 588980c0d4
3 changed files with 14 additions and 3 deletions

View file

@ -1,3 +1,13 @@
2016-09-19 Niels Grewe <niels.grewe@halbordnung.de>>
* Source/Additions/GSMime.m (charsetForXml):
Fix detection of charset in XML document.
* Tests/base/GSMime/xml-charset.m: Test case.
2016-09-16 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/Additions/GSMime.m (convertTo7BitSafe):
2016-09-16 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/Additions/GSMime.m (convertTo7BitSafe):

View file

@ -4764,7 +4764,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
{
/* Extract the charset and return it.
*/
r = NSMakeRange(index, r.length - index);
r = NSMakeRange(index, r.location - index);
return [xml substringWithRange: r];
}
}

View file

@ -8,9 +8,10 @@ int main()
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSString *xml = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?><html></html>";
NSString *charset = nil;
testHopeful = YES;
PASS_RUNS(charset = [GSMimeDocument charsetForXml: xml], "Can determine cahrset of xml document.");
PASS_RUNS(charset = [GSMimeDocument charsetForXml: xml], "Can determine charset of xml document.");
PASS_EQUAL(@"UTF-8", charset, "Charset detected correctly");
DESTROY(arp);
return 0;
}
#else
int main(int argc,char **argv)