Commit b3ebb432 authored by ggaren's avatar ggaren

Reviewed and landed by Geoff.

        - fix a regression in ecma_3/String/regress-104375.js

        * kjs/string_object.cpp:
        (substituteBackreferences): If a 2-digit back reference is out of range,
        parse it as a 1-digit reference (followed by the other digit). This matches
        Firefox's behavior.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@14742 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b3562e42
2006-06-05 Mitz Pettel <opendarwin.org@mitzpettel.com>
Reviewed and landed by Geoff.
- fix a regression in ecma_3/String/regress-104375.js
* kjs/string_object.cpp:
(substituteBackreferences): If a 2-digit back reference is out of range,
parse it as a 1-digit reference (followed by the other digit). This matches
Firefox's behavior.
2006-06-05 Geoffrey Garen <ggaren@apple.com> 2006-06-05 Geoffrey Garen <ggaren@apple.com>
Reviewed By Maciej. Reviewed By Maciej.
......
...@@ -257,17 +257,18 @@ static inline UString substituteBackreferences(const UString &replacement, const ...@@ -257,17 +257,18 @@ static inline UString substituteBackreferences(const UString &replacement, const
} else if (ref >= '0' && ref <= '9') { } else if (ref >= '0' && ref <= '9') {
// 1- and 2-digit back references are allowed // 1- and 2-digit back references are allowed
unsigned backrefIndex = ref - '0'; unsigned backrefIndex = ref - '0';
if (backrefIndex > (unsigned)reg->subPatterns())
continue;
if (substitutedReplacement.size() > i + 2) { if (substitutedReplacement.size() > i + 2) {
ref = substitutedReplacement[i+2].unicode(); ref = substitutedReplacement[i+2].unicode();
if (ref >= '0' && ref <= '9') { if (ref >= '0' && ref <= '9') {
backrefIndex = 10 * backrefIndex + ref - '0'; backrefIndex = 10 * backrefIndex + ref - '0';
advance = 1; if (backrefIndex > (unsigned)reg->subPatterns())
backrefIndex = backrefIndex / 10; // Fall back to the 1-digit reference
else
advance = 1;
} }
} }
if (backrefIndex > (unsigned)reg->subPatterns()) {
i += advance;
continue;
}
backrefStart = ovector[2 * backrefIndex]; backrefStart = ovector[2 * backrefIndex];
backrefLength = ovector[2 * backrefIndex + 1] - backrefStart; backrefLength = ovector[2 * backrefIndex + 1] - backrefStart;
} else } else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment