V8 Project
v8::internal::URIUnescape Class Reference
+ Inheritance diagram for v8::internal::URIUnescape:
+ Collaboration diagram for v8::internal::URIUnescape:

Public Member Functions

template<typename Char >
MaybeHandle< StringUnescape (Isolate *isolate, Handle< String > source)
 
template<typename Char >
MaybeHandle< StringUnescapeSlow (Isolate *isolate, Handle< String > string, int start_index)
 

Static Public Member Functions

template<typename Char >
static MUST_USE_RESULT MaybeHandle< StringUnescape (Isolate *isolate, Handle< String > source)
 

Static Private Member Functions

template<typename Char >
static MUST_USE_RESULT MaybeHandle< StringUnescapeSlow (Isolate *isolate, Handle< String > string, int start_index)
 
static INLINE (int TwoDigitHex(uint16_t character1, uint16_t character2))
 
template<typename Char >
static INLINE (int UnescapeChar(Vector< const Char > vector, int i, int length, int *step))
 

Static Private Attributes

static const signed char kHexValue ['g']
 

Detailed Description

Definition at line 38 of file runtime-uri.cc.

Member Function Documentation

◆ INLINE() [1/2]

static v8::internal::URIUnescape::INLINE ( int   TwoDigitHexuint16_t character1, uint16_t character2)
staticprivate

◆ INLINE() [2/2]

template<typename Char >
static v8::internal::URIUnescape::INLINE ( int   UnescapeCharVector< const Char > vector, int i, int length, int *step)
staticprivate

◆ Unescape() [1/2]

template<typename Char >
static MUST_USE_RESULT MaybeHandle<String> v8::internal::URIUnescape::Unescape ( Isolate isolate,
Handle< String source 
)
static

◆ Unescape() [2/2]

template<typename Char >
MaybeHandle<String> v8::internal::URIUnescape::Unescape ( Isolate isolate,
Handle< String source 
)

Definition at line 70 of file runtime-uri.cc.

71  {
72  int index;
73  {
74  DisallowHeapAllocation no_allocation;
75  StringSearch<uint8_t, Char> search(isolate, STATIC_CHAR_VECTOR("%"));
76  index = search.Search(GetCharVector<Char>(source), 0);
77  if (index < 0) return source;
78  }
79  return UnescapeSlow<Char>(isolate, source, index);
80 }
PerThreadAssertScopeDebugOnly< HEAP_ALLOCATION_ASSERT, false > DisallowHeapAllocation
Definition: assert-scope.h:110
#define STATIC_CHAR_VECTOR(x)
Definition: vector.h:154

References v8::internal::StringSearch< PatternChar, SubjectChar >::Search(), and STATIC_CHAR_VECTOR.

+ Here is the call graph for this function:

◆ UnescapeSlow() [1/2]

template<typename Char >
static MUST_USE_RESULT MaybeHandle<String> v8::internal::URIUnescape::UnescapeSlow ( Isolate isolate,
Handle< String string,
int  start_index 
)
staticprivate

◆ UnescapeSlow() [2/2]

template<typename Char >
MaybeHandle<String> v8::internal::URIUnescape::UnescapeSlow ( Isolate isolate,
Handle< String string,
int  start_index 
)

Definition at line 84 of file runtime-uri.cc.

86  {
87  bool one_byte = true;
88  int length = string->length();
89 
90  int unescaped_length = 0;
91  {
92  DisallowHeapAllocation no_allocation;
93  Vector<const Char> vector = GetCharVector<Char>(string);
94  for (int i = start_index; i < length; unescaped_length++) {
95  int step;
96  if (UnescapeChar(vector, i, length, &step) >
98  one_byte = false;
99  }
100  i += step;
101  }
102  }
103 
104  DCHECK(start_index < length);
105  Handle<String> first_part =
106  isolate->factory()->NewProperSubString(string, 0, start_index);
107 
108  int dest_position = 0;
109  Handle<String> second_part;
110  DCHECK(unescaped_length <= String::kMaxLength);
111  if (one_byte) {
112  Handle<SeqOneByteString> dest = isolate->factory()
113  ->NewRawOneByteString(unescaped_length)
114  .ToHandleChecked();
115  DisallowHeapAllocation no_allocation;
116  Vector<const Char> vector = GetCharVector<Char>(string);
117  for (int i = start_index; i < length; dest_position++) {
118  int step;
119  dest->SeqOneByteStringSet(dest_position,
120  UnescapeChar(vector, i, length, &step));
121  i += step;
122  }
123  second_part = dest;
124  } else {
125  Handle<SeqTwoByteString> dest = isolate->factory()
126  ->NewRawTwoByteString(unescaped_length)
127  .ToHandleChecked();
128  DisallowHeapAllocation no_allocation;
129  Vector<const Char> vector = GetCharVector<Char>(string);
130  for (int i = start_index; i < length; dest_position++) {
131  int step;
132  dest->SeqTwoByteStringSet(dest_position,
133  UnescapeChar(vector, i, length, &step));
134  i += step;
135  }
136  second_part = dest;
137  }
138  return isolate->factory()->NewConsString(first_part, second_part);
139 }
static const int32_t kMaxOneByteCharCode
Definition: objects.h:8811
static const int kMaxLength
Definition: objects.h:8820
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, v8::internal::Isolate::factory(), v8::internal::String::kMaxLength, and v8::internal::String::kMaxOneByteCharCode.

+ Here is the call graph for this function:

Member Data Documentation

◆ kHexValue

const signed char v8::internal::URIUnescape::kHexValue
staticprivate
Initial value:
= {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -0, 1, 2, 3, 4, 5,
6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15}

Definition at line 45 of file runtime-uri.cc.


The documentation for this class was generated from the following file: