mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
Fix StringObject::defineOwnProperty
* Check if this is an index property within the string length due to proxy object Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
2e9a6393b9
commit
121d2fefca
1 changed files with 12 additions and 0 deletions
|
|
@ -77,6 +77,18 @@ ObjectGetResult StringObject::getOwnProperty(ExecutionState& state, const Object
|
|||
|
||||
bool StringObject::defineOwnProperty(ExecutionState& state, const ObjectPropertyName& P, const ObjectPropertyDescriptor& desc)
|
||||
{
|
||||
// Check if this is an index property within the string length
|
||||
// String index properties are non-configurable and non-writable per ECMAScript spec
|
||||
// We must reject any attempt to define a property on these indexed positions
|
||||
size_t idx = P.tryToUseAsIndexProperty();
|
||||
if (idx != Value::InvalidIndexPropertyValue) {
|
||||
size_t strLen = m_primitiveValue->length();
|
||||
if (idx < strLen) {
|
||||
// Indexed properties within string length are non-configurable
|
||||
// Per ECMAScript spec, defining a non-configurable property should fail
|
||||
return false;
|
||||
}
|
||||
}
|
||||
auto r = getOwnProperty(state, P);
|
||||
if (r.hasValue() && !r.isConfigurable())
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue