Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In XMLDictionary.m , in function - (NSDictionary *)attributes #17

Open
kstang opened this issue Sep 4, 2014 · 0 comments
Open

In XMLDictionary.m , in function - (NSDictionary *)attributes #17

kstang opened this issue Sep 4, 2014 · 0 comments

Comments

@kstang
Copy link

kstang commented Sep 4, 2014

when //it may happened when _[name] and [name] are both exist on XML creation, a name collision may be possible in function - (NSDictionary *)attributes . My use case is using this llbrary as the XML writer .

Found name collision in 64bit simulator, as the sequence [filteredDict allKeys] is indefinite

Fix had been applied as follow , please advice :

  • (NSDictionary *)attributes
    {
    NSDictionary *attributes = self[XMLDictionaryAttributesKey];
    if (attributes)
    {
    return [attributes count]? attributes: nil;
    }
    else
    {
    NSMutableDictionary *filteredDict = [NSMutableDictionary dictionaryWithDictionary:self];
    [filteredDict removeObjectsForKeys:@[XMLDictionaryCommentsKey, XMLDictionaryTextKey, XMLDictionaryNodeNameKey]];

    //it is mean to prevent the key collision issue for xml creation
    //I guess the performance impact on this should be minimal
    //start patch 
    for (NSString *key in  [filteredDict allKeys])
    {
    
        if (![key hasPrefix:XMLDictionaryAttributePrefix])
        {
             [filteredDict removeObjectForKey:key];
        }
    }
    //end patch
    for (NSString *key in [filteredDict allKeys])
    {
        [filteredDict removeObjectForKey:key];
        if ([key hasPrefix:XMLDictionaryAttributePrefix])
        {
           // currAttriValue= self[key];
            filteredDict[[key substringFromIndex:[XMLDictionaryAttributePrefix length]]] = self[key];
        }
    }
    return [filteredDict count]? filteredDict: nil;
    

    }
    return nil;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant