diff options
Diffstat (limited to 'JavaScriptCore/wtf/text/StringImpl.cpp')
-rw-r--r-- | JavaScriptCore/wtf/text/StringImpl.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/JavaScriptCore/wtf/text/StringImpl.cpp b/JavaScriptCore/wtf/text/StringImpl.cpp index 1c4de66..c83ec42 100644 --- a/JavaScriptCore/wtf/text/StringImpl.cpp +++ b/JavaScriptCore/wtf/text/StringImpl.cpp @@ -270,12 +270,17 @@ PassRefPtr<StringImpl> StringImpl::upper() return newImpl.release(); } -PassRefPtr<StringImpl> StringImpl::secure(UChar character) +PassRefPtr<StringImpl> StringImpl::secure(UChar character, LastCharacterBehavior behavior) { + if (!m_length) + return this; + UChar* data; RefPtr<StringImpl> newImpl = createUninitialized(m_length, data); - for (unsigned i = 0; i < m_length; ++i) + unsigned lastCharacterIndex = m_length - 1; + for (unsigned i = 0; i < lastCharacterIndex; ++i) data[i] = character; + data[lastCharacterIndex] = (behavior == ObscureLastCharacter) ? character : m_data[lastCharacterIndex]; return newImpl.release(); } |