18 template <
typename Char>
32 String::FlatContent flat =
string->GetFlatContent();
34 return flat.ToUC16Vector();
40 template <
typename Char>
47 template <
typename Char>
54 template <
typename Char>
61 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
62 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
63 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -0, 1, 2, 3, 4, 5,
64 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1,
65 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
66 -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15};
69 template <
typename Char>
76 index = search.
Search(GetCharVector<Char>(source), 0);
77 if (index < 0)
return source;
79 return UnescapeSlow<Char>(isolate, source, index);
83 template <
typename Char>
88 int length =
string->length();
90 int unescaped_length = 0;
94 for (
int i = start_index;
i < length; unescaped_length++) {
96 if (UnescapeChar(vector,
i, length, &step) >
104 DCHECK(start_index < length);
106 isolate->
factory()->NewProperSubString(
string, 0, start_index);
108 int dest_position = 0;
113 ->NewRawOneByteString(unescaped_length)
117 for (
int i = start_index;
i < length; dest_position++) {
119 dest->SeqOneByteStringSet(dest_position,
120 UnescapeChar(vector,
i, length, &step));
126 ->NewRawTwoByteString(unescaped_length)
130 for (
int i = start_index;
i < length; dest_position++) {
132 dest->SeqTwoByteStringSet(dest_position,
133 UnescapeChar(vector,
i, length, &step));
138 return isolate->
factory()->NewConsString(first_part, second_part);
143 if (character1 >
'f')
return -1;
145 if (
hi == -1)
return -1;
146 if (character2 >
'f')
return -1;
148 if (
lo == -1)
return -1;
149 return (
hi << 4) +
lo;
153 template <
typename Char>
154 int URIUnescape::UnescapeChar(Vector<const Char> vector,
int i,
int length,
159 if (character ==
'%' &&
i <= length - 6 && vector[
i + 1] ==
'u' &&
160 (
hi = TwoDigitHex(vector[
i + 2], vector[
i + 3])) != -1 &&
161 (
lo = TwoDigitHex(vector[
i + 4], vector[
i + 5])) != -1) {
163 return (
hi << 8) +
lo;
164 }
else if (character ==
'%' &&
i <= length - 3 &&
165 (
lo = TwoDigitHex(vector[
i + 1], vector[
i + 2])) != -1) {
177 template <
typename Char>
204 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
205 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1,
206 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
207 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
208 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
209 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
210 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
211 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
212 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
213 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
214 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
217 template <
typename Char>
220 int escaped_length = 0;
221 int length =
string->length();
226 for (
int i = 0;
i < length;
i++) {
243 if (escaped_length == length)
return string;
247 isolate, dest, isolate->
factory()->NewRawOneByteString(escaped_length),
249 int dest_position = 0;
254 for (
int i = 0;
i < length;
i++) {
257 dest->SeqOneByteStringSet(dest_position,
'%');
258 dest->SeqOneByteStringSet(dest_position + 1,
'u');
259 dest->SeqOneByteStringSet(dest_position + 2,
kHexChars[c >> 12]);
260 dest->SeqOneByteStringSet(dest_position + 3,
kHexChars[(c >> 8) & 0xf]);
261 dest->SeqOneByteStringSet(dest_position + 4,
kHexChars[(c >> 4) & 0xf]);
262 dest->SeqOneByteStringSet(dest_position + 5,
kHexChars[c & 0xf]);
265 dest->SeqOneByteStringSet(dest_position, c);
268 dest->SeqOneByteStringSet(dest_position,
'%');
269 dest->SeqOneByteStringSet(dest_position + 1,
kHexChars[c >> 4]);
270 dest->SeqOneByteStringSet(dest_position + 2,
kHexChars[c & 0xf]);
282 DCHECK(args.length() == 1);
288 isolate, result, string->IsOneByteRepresentationUnderneath()
289 ? URIEscape::Escape<uint8_t>(isolate, source)
290 : URIEscape::Escape<uc16>(isolate, source));
297 DCHECK(args.length() == 1);
303 isolate, result, string->IsOneByteRepresentationUnderneath()
304 ? URIUnescape::Unescape<uint8_t>(isolate, source)
305 : URIUnescape::Unescape<uc16>(isolate, source));
An object reference managed by the v8 garbage collector.
int Search(Vector< const SubjectChar > subject, int index)
Vector< const uint8_t > ToOneByteVector()
static const int32_t kMaxOneByteCharCode
static const int kMaxLength
static Handle< String > Flatten(Handle< String > string, PretenureFlag pretenure=NOT_TENURED)
static bool IsNotEscaped(uint16_t c)
static const char kHexChars[17]
static MUST_USE_RESULT MaybeHandle< String > Escape(Isolate *isolate, Handle< String > string)
static const char kNotEscaped[256]
static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2))
static MUST_USE_RESULT MaybeHandle< String > Unescape(Isolate *isolate, Handle< String > source)
static MUST_USE_RESULT MaybeHandle< String > UnescapeSlow(Isolate *isolate, Handle< String > string, int start_index)
static INLINE(int UnescapeChar(Vector< const Char > vector, int i, int length, int *step))
static const signed char kHexValue['g']
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
#define ASSIGN_RETURN_ON_EXCEPTION(isolate, dst, call, T)
#define DCHECK(condition)
Vector< const uint8_t > GetCharVector(Handle< String > string)
INLINE(static HeapObject *EnsureDoubleAligned(Heap *heap, HeapObject *object, int size))
Debugger support for the V8 JavaScript engine.
#define CONVERT_ARG_HANDLE_CHECKED(Type, name, index)
#define STATIC_CHAR_VECTOR(x)