bugGNUstep - Bugs: bug #33244, NSXMLParser doesn't parse some...

Group
 
 

bug #33244: NSXMLParser doesn't parse some gsdoc files due to encoding detection

Submitter:  Quentin Mathé <qmathe>
Submitted:  Fri 06 May 2011 11:48:23 AM UTC
   
 
Category:  Base/Foundation Severity:  3 - Normal
Item Group:  Bug Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 15 May 2011 12:30:31 PM UTC, comment #2: 

Yes, the problem is solved now.

Thanks.

Quentin Mathé <qmathe>
Group Member
Thu 12 May 2011 08:34:35 AM UTC, comment #1: 

Richard submitted a fix for the XML parser, does this solve the problem?

Fred Kiefer <FredKiefer>
Group Member
Fri 06 May 2011 11:48:23 AM UTC, original submission:  

GNUstep Base r32961

Hi,

When parsing some gsdoc files with a xml parser set up as below:

NSString *content = [NSString stringWithContentsOfFile: gsdocPath encoding: NSUTF8StringEncoding error: NULL];

xmlParser = [[NSXMLParser alloc] initWithData: [aContent dataUsingEncoding: NSUTF8StringEncoding]];

I observe that -[NSXMLParser initWithData:] isn't able to generate a valid string from the data.

Here is what a debugging session gives with NSData+Hash.gsdoc (in attachment)...
The issue seems to be that -[GSMimeDocument encodingFromCharset:] in -[SloppyXMLParser initWithData:] returns GSUndefinedEncoding rather than NSUTF8StringEncoding.

Breakpoint 6, -[NSXMLParser initWithData:] (self=0x89655e0, _cmd=0x80bdb38, data=0x898b510)
    at NSXMLParser.m:739
739   if (data == nil)
(gdb) n
745       self = [super init];
(gdb)
746       if (self)
(gdb)
750   _parser = [GSXMLParserIvars new];
(gdb)
753   enc = [GSMimeDocument encodingFromCharset:
(gdb)
755   if (enc == NSUTF8StringEncoding || enc == NSASCIIStringEncoding)
(gdb)
763       tmp = [[NSString alloc] initWithData: data encoding: enc];
(gdb)
764       this->data
(gdb) po tmp
Cannot access memory at address 0x0
(gdb) po data
<3c3f786d 6c207665 7273696f 6e3d2231 2e30223f 3e0a3c21 444f4354 59504520 6773646f 63205055 424c4943 20222d2f 2f474e55 73746570 2f2f4454 44206773 646f6320 312e302e 332f2f45 4e222022 68747470 3a2f2f77 77772e67 6e757374 65702e6f 72672f67 73646f63 2d315f30 5f332e64 7464223e 0a3c6773 646f6320 62617365 3d224e53 44617461 2b486173 68223e0a 20203c68 6561643e 0a202020 203c7469 746c653e [snip]
(gdb) p enc
$3 = GSUndefinedEncoding

Thanks,
Quentin.

Quentin Mathé <qmathe>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #23358:  NSData+Hash.gsdoc added by qmathe (3KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by FredKiefer (Posted a comment)
  • -email is unavailable- added by qmathe (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-05-15 qmathe Open/ClosedOpen Closed
    2011-05-15 qmathe StatusNone Fixed
    2011-05-06 qmathe Attached File- Added NSData+Hash.gsdoc, #23358

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code