diff options
Diffstat (limited to 'chromium/v8/src/uri.h')
-rw-r--r-- | chromium/v8/src/uri.h | 71 |
1 files changed, 26 insertions, 45 deletions
diff --git a/chromium/v8/src/uri.h b/chromium/v8/src/uri.h index ee1baeb5129..a35ee9919d5 100644 --- a/chromium/v8/src/uri.h +++ b/chromium/v8/src/uri.h @@ -1,38 +1,15 @@ // Copyright 2013 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef V8_URI_H_ #define V8_URI_H_ -#include "v8.h" +#include "src/v8.h" -#include "string-search.h" -#include "v8utils.h" -#include "v8conversions.h" +#include "src/conversions.h" +#include "src/string-search.h" +#include "src/utils.h" namespace v8 { namespace internal { @@ -61,13 +38,14 @@ Vector<const uc16> GetCharVector(Handle<String> string) { class URIUnescape : public AllStatic { public: template<typename Char> - static Handle<String> Unescape(Isolate* isolate, Handle<String> source); + MUST_USE_RESULT static MaybeHandle<String> Unescape(Isolate* isolate, + Handle<String> source); private: static const signed char kHexValue['g']; template<typename Char> - static Handle<String> UnescapeSlow( + MUST_USE_RESULT static MaybeHandle<String> UnescapeSlow( Isolate* isolate, Handle<String> string, int start_index); static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2)); @@ -91,7 +69,8 @@ const signed char URIUnescape::kHexValue[] = { template<typename Char> -Handle<String> URIUnescape::Unescape(Isolate* isolate, Handle<String> source) { +MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, + Handle<String> source) { int index; { DisallowHeapAllocation no_allocation; StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%")); @@ -103,7 +82,7 @@ Handle<String> URIUnescape::Unescape(Isolate* isolate, Handle<String> source) { template <typename Char> -Handle<String> URIUnescape::UnescapeSlow( +MaybeHandle<String> URIUnescape::UnescapeSlow( Isolate* isolate, Handle<String> string, int start_index) { bool one_byte = true; int length = string->length(); @@ -127,9 +106,10 @@ Handle<String> URIUnescape::UnescapeSlow( int dest_position = 0; Handle<String> second_part; + ASSERT(unescaped_length <= String::kMaxLength); if (one_byte) { - Handle<SeqOneByteString> dest = - isolate->factory()->NewRawOneByteString(unescaped_length); + Handle<SeqOneByteString> dest = isolate->factory()->NewRawOneByteString( + unescaped_length).ToHandleChecked(); DisallowHeapAllocation no_allocation; Vector<const Char> vector = GetCharVector<Char>(string); for (int i = start_index; i < length; dest_position++) { @@ -140,8 +120,8 @@ Handle<String> URIUnescape::UnescapeSlow( } second_part = dest; } else { - Handle<SeqTwoByteString> dest = - isolate->factory()->NewRawTwoByteString(unescaped_length); + Handle<SeqTwoByteString> dest = isolate->factory()->NewRawTwoByteString( + unescaped_length).ToHandleChecked(); DisallowHeapAllocation no_allocation; Vector<const Char> vector = GetCharVector<Char>(string); for (int i = start_index; i < length; dest_position++) { @@ -200,7 +180,8 @@ int URIUnescape::UnescapeChar(Vector<const Char> vector, class URIEscape : public AllStatic { public: template<typename Char> - static Handle<String> Escape(Isolate* isolate, Handle<String> string); + MUST_USE_RESULT static MaybeHandle<String> Escape(Isolate* isolate, + Handle<String> string); private: static const char kHexChars[17]; @@ -244,7 +225,7 @@ const char URIEscape::kNotEscaped[] = { template<typename Char> -Handle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) { +MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) { ASSERT(string->IsFlat()); int escaped_length = 0; int length = string->length(); @@ -263,18 +244,18 @@ Handle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) { // We don't allow strings that are longer than a maximal length. ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow. - if (escaped_length > String::kMaxLength) { - isolate->context()->mark_out_of_memory(); - return Handle<String>::null(); - } + if (escaped_length > String::kMaxLength) break; // Provoke exception. } } // No length change implies no change. Return original string if no change. if (escaped_length == length) return string; - Handle<SeqOneByteString> dest = - isolate->factory()->NewRawOneByteString(escaped_length); + Handle<SeqOneByteString> dest; + ASSIGN_RETURN_ON_EXCEPTION( + isolate, dest, + isolate->factory()->NewRawOneByteString(escaped_length), + String); int dest_position = 0; { DisallowHeapAllocation no_allocation; |