mattt/Ono

Crash inside -[ONOXMLElement attributes] for "description" key

chrisballinger opened this issue · 3 comments

- (NSDictionary *)attributes {
    if (!_attributes) {
        NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionary];
        for (xmlAttrPtr attribute = self.xmlNode->properties; attribute != NULL; attribute = attribute->next) {
            NSString *key = @((const char *)attribute->name);
            // valueForAttribute is nil for 'description'
            [mutableAttributes setObject:[self valueForAttribute:key] forKey:key];
        }

        self.attributes = [NSDictionary dictionaryWithDictionary:mutableAttributes];
    }

    return _attributes;
}

Sample:

<outline text="BBC Persian" description="&lt;div style=&quot;direction:rtl;text-align:right&quot;&gt;&#x627;&#x6CC;&#x646; &#x635;&#x641;&#x62D;&#x647; &#x62F;&#x6CC;&#x6AF;&#x631; &#x628;&#x647; &#x631;&#x648;&#x62E;.." htmlUrl="http://www.bbc.co.uk/blogs/persian/editors/" xmlUrl="http://www.bbc.co.uk/blogs/persian/editors/rss.xml" subscribe="false" content_type="text/xml" site_icon="http://www.bbc.co.uk/favicon.ico"/>

@chrisballinger I tried parsing this xml but were not able to reproduce it. Would you mind sharing the whole xml file and the code?

mattt commented

Hi, @chrisballinger. Sorry for not responding sooner.

I can't reproduce this either. If you're still having this issue, please submit a PR with a failing test case, and I'd be more than happy to look into it for you.

I have same issue.
this will produce

- (LeMobileTemplateItem *)createTemplateItemWithData:(NSDictionary *)data  {
   ONOXMLDocument *doc =  [ONOXMLDocument XMLDocumentWithString:self.xmlElementString encoding:NSUTF8StringEncoding error:nil];
    ONOXMLElement *childElement = doc;
    LeMobileTemplateItem *templateItem = [[LeMobileTemplateItem alloc] initWithXmlElement:childElement.children.firstObject data:data controllerClass:self.controllerClass];
    return templateItem;
}

but code below not

- (LeMobileTemplateItem *)createTemplateItemWithData:(NSDictionary *)data  {
//    ONOXMLDocument *doc =  [ONOXMLDocument XMLDocumentWithString:self.xmlElementString encoding:NSUTF8StringEncoding error:nil];
    ONOXMLElement *childElement = self.doc.rootElement;
    LeMobileTemplateItem *templateItem = [[LeMobileTemplateItem alloc] initWithXmlElement:childElement.children.firstObject data:data controllerClass:self.controllerClass];
    return templateItem;
}

I think, it is bad pointer