fix(table-core): prototype-named column ids poisoning row value caches#1
Closed
artchen-db wants to merge 1 commit into
Closed
fix(table-core): prototype-named column ids poisoning row value caches#1artchen-db wants to merge 1 commit into
artchen-db wants to merge 1 commit into
Conversation
Row value caches (_valuesCache, _uniqueValuesCache, _groupingValuesCache) were plain objects probed with cache.hasOwnProperty(columnId). A column whose id collided with an Object.prototype member (e.g. hasOwnProperty) shadowed the inherited method on write, so the next probe invoked a cached value as a function and threw TypeError, crashing filtering and sorting. Caches are now created with Object.create(null) and read via Object.prototype.hasOwnProperty.call. _getAllCellsByColumnId is likewise null-prototyped so prototype-named ids resolve correctly when read via bracket access in getColumnCanGlobalFilter. Co-authored-by: Isaac
|
Hi! I'm the It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃 |
Owner
Author
|
Superseded by upstream PR against TanStack/table. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A column whose
idequals anObject.prototypemember (e.g.hasOwnProperty) crashes filtering/sorting:Root cause
Per-row caches are plain
{}objects probed withcache.hasOwnProperty(columnId), then written keyed by column id. WhencolumnId === "hasOwnProperty", the write shadows the inherited method, so the next probe invokes a cached value as a function and throws.Fix
Initialize the caches (
_valuesCache,_uniqueValuesCache,_groupingValuesCache) withObject.create(null)and read them viaObject.prototype.hasOwnProperty.call(...). Also null-prototype_getAllCellsByColumnIdso ids liketoString/constructorresolve correctly when read via bracket access ingetColumnCanGlobalFilter. This removes the entire prototype-collision class for these caches.Tests
Added
tests/prototypeColumnId.test.tscoveringgetValue,getUniqueValues, and the cascading-failure case acrosshasOwnProperty,toString,constructor,valueOf,__proto__,isPrototypeOf. Fails without the fix, passes with it. Fulltable-coresuite (27 tests) andtsc --noEmitpass.