-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX beta] Negative indices in positional
args proxy
#19273
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it may be better to change convertToInt
to return null
for negative indices.
@pzuraq / @krisselden - What do you think?
@@ -101,7 +101,7 @@ if (HAS_NATIVE_PROXY) { | |||
|
|||
const parsed = convertToInt(prop); | |||
|
|||
if (parsed !== null && parsed < positional.length) { | |||
if (parsed !== null && parsed >= 0 && parsed < positional.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this fix is quite enough (we have the exact same type of check in has
).
Also, we need a test for this behavior (confirming that modifiers,helpers, and components can access |
Cool! Let me know on the way forward regarding:
I'll update the PR then and add tests. 🧪 |
Oh, also, what is the error here? |
ember.js/packages/@ember/-internals/glimmer/lib/utils/args-proxy.ts Lines 104 to 106 in 0f3266c
|
Just chatted with @pzuraq / @krisselden about this, lets do it this way. I think that would look something like: function convertToInt(prop: number | string | symbol): number | null {
if (typeof prop === 'symbol') return null;
const num = Number(prop);
if (isNaN(num)) return null;
return num % 1 === 0 && num > -1 ? num : null;
} Then we just need some tests, and to update the commit message/PR title to |
Is this still relevant? |
In
ember-link
I had code that potentially accessed a negative index on apositional
args proxy, which used to returnundefined
. Starting with the3.23.0
beta, this throws an error.This is because only the upper bound is checked.