diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c index 08aa14497..d9d7676fa 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-global.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-global.c @@ -1316,6 +1316,12 @@ ecma_builtin_global_object_unescape (ecma_value_t this_arg, /**< this argument * hex_digits = (ecma_char_t) (hex_digits * 16 + (ecma_char_t) lit_char_hex_to_int (chr)); status++; } + else + { + /* Previously found hexadecimal digit in escape sequence but it's not valid '%xy' pattern + * so essentially it was only a simple character. */ + status = 0; + } /* 11-17. Found valid '%uwxyz' or '%xy' escape. */ if (status == 8 || status == 3) diff --git a/tests/jerry/regression-test-issue-1990.js b/tests/jerry/regression-test-issue-1990.js new file mode 100644 index 000000000..5bd48cccd --- /dev/null +++ b/tests/jerry/regression-test-issue-1990.js @@ -0,0 +1,15 @@ +// Copyright JS Foundation and other contributors, http://js.foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +assert(unescape("%f׊nd") === "%f׊nd")