Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Fix O(n^2) behavior when checking for duplicate attributes #144

Closed
stevecheckoway opened this issue Apr 27, 2020 · 3 comments
Closed

Fix O(n^2) behavior when checking for duplicate attributes #144

stevecheckoway opened this issue Apr 27, 2020 · 3 comments
Assignees

Comments

@stevecheckoway
Copy link
Collaborator

Code in question is here.

This can lead to a DoS. See #143.

@stevecheckoway stevecheckoway self-assigned this Apr 27, 2020
@flavorjones
Copy link
Collaborator

@stevecheckoway Do we still need to address this? If so, should we move this issue over to Nokogiri?

@stevecheckoway
Copy link
Collaborator Author

I think so.

My recollection is that libxml2 checks for duplicate attributes whenever an attribute is added to an element and the only way it has to do this is by walking the linked list of attributes.

If we want to manipulate the xmlNode structure directly rather than calling functions to modify it, we should be able to get amortized O(n) behavior by collecting the set of attributes to add and checking for duplicates.

@flavorjones
Copy link
Collaborator

Moved to sparklemotion/nokogiri#2568

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

No branches or pull requests

2 participants