Skip to content
This repository was archived by the owner on Oct 8, 2023. It is now read-only.

The recursivity of normalizeData method in TreeGrid class is potentially endless with only-numbers string as key and parentKey #31

@ovargas71

Description

@ovargas71

The problem:

If the values of keyColumnName and parentColumnName fields are strings with only numeric character, the recursivity of normalizeData method in TreeGrid class is potentially endless.

Example case:

For example, if we have the follow data (informal code):

Node1: [key = "1", parentKey = null]

Node2: [key = "01", parentKey = "1"]

Node3: [key = "001", parentKey = "01"]

When is searching then Node2's children (value of $parentId parameter is "01"), because Node2's parentKey is "1", the condition ArrayHelper::getValue($element, $this->parentColumnName) == $parentId is evaluated true, therefore a new call to normalizeData is thrown to search (again) the Node2's children.

Suggested modification:

Use the type-strict comparation operator (===) instead the double equal operator (==).

ArrayHelper::getValue($element, $this->parentColumnName) === $parentId

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions