Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(233)

Side by Side Diff: src/uri.cc

Issue 2135573002: Address compilation warnings for android build. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update comment. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/scanner.h ('k') | test/cctest/interpreter/test-source-positions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/uri.h" 5 #include "src/uri.h"
6 6
7 #include "src/char-predicates-inl.h" 7 #include "src/char-predicates-inl.h"
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/isolate-inl.h" 9 #include "src/isolate-inl.h"
10 #include "src/list.h" 10 #include "src/list.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } else { 85 } else {
86 buffer->Add(decoded); 86 buffer->Add(decoded);
87 } 87 }
88 } 88 }
89 89
90 bool IntoTwoByte(int index, bool is_uri, int uri_length, 90 bool IntoTwoByte(int index, bool is_uri, int uri_length,
91 String::FlatContent* uri_content, List<uc16>* buffer) { 91 String::FlatContent* uri_content, List<uc16>* buffer) {
92 for (int k = index; k < uri_length; k++) { 92 for (int k = index; k < uri_length; k++) {
93 uc16 code = uri_content->Get(k); 93 uc16 code = uri_content->Get(k);
94 if (code == '%') { 94 if (code == '%') {
95 uc16 decoded; 95 int two_digits;
96 if (k + 2 >= uri_length || 96 if (k + 2 >= uri_length ||
97 (decoded = TwoDigitHex(uri_content->Get(k + 1), 97 (two_digits = TwoDigitHex(uri_content->Get(k + 1),
98 uri_content->Get(k + 2))) < 0) { 98 uri_content->Get(k + 2))) < 0) {
99 return false; 99 return false;
100 } 100 }
101 k += 2; 101 k += 2;
102 uc16 decoded = static_cast<uc16>(two_digits);
102 if (decoded > unibrow::Utf8::kMaxOneByteChar) { 103 if (decoded > unibrow::Utf8::kMaxOneByteChar) {
103 uint8_t octets[unibrow::Utf8::kMaxEncodedSize]; 104 uint8_t octets[unibrow::Utf8::kMaxEncodedSize];
104 octets[0] = decoded; 105 octets[0] = decoded;
105 106
106 int number_of_continuation_bytes = 0; 107 int number_of_continuation_bytes = 0;
107 while ((decoded << ++number_of_continuation_bytes) & 0x80) { 108 while ((decoded << ++number_of_continuation_bytes) & 0x80) {
108 if (number_of_continuation_bytes > 3 || k + 3 >= uri_length) { 109 if (number_of_continuation_bytes > 3 || k + 3 >= uri_length) {
109 return false; 110 return false;
110 } 111 }
111
112 uc16 continuation_byte;
113
114 if (uri_content->Get(++k) != '%' || 112 if (uri_content->Get(++k) != '%' ||
115 (continuation_byte = TwoDigitHex(uri_content->Get(k + 1), 113 (two_digits = TwoDigitHex(uri_content->Get(k + 1),
116 uri_content->Get(k + 2))) < 0) { 114 uri_content->Get(k + 2))) < 0) {
117 return false; 115 return false;
118 } 116 }
119 k += 2; 117 k += 2;
118 uc16 continuation_byte = static_cast<uc16>(two_digits);
120 octets[number_of_continuation_bytes] = continuation_byte; 119 octets[number_of_continuation_bytes] = continuation_byte;
121 } 120 }
122 121
123 if (!DecodeOctets(octets, number_of_continuation_bytes, buffer)) { 122 if (!DecodeOctets(octets, number_of_continuation_bytes, buffer)) {
124 return false; 123 return false;
125 } 124 }
126 } else { 125 } else {
127 AddToBuffer(decoded, uri_content, k - 2, is_uri, buffer); 126 AddToBuffer(decoded, uri_content, k - 2, is_uri, buffer);
128 } 127 }
129 } else { 128 } else {
130 buffer->Add(code); 129 buffer->Add(code);
131 } 130 }
132 } 131 }
133 return true; 132 return true;
134 } 133 }
135 134
136 bool IntoOneAndTwoByte(Handle<String> uri, bool is_uri, 135 bool IntoOneAndTwoByte(Handle<String> uri, bool is_uri,
137 List<uint8_t>* one_byte_buffer, 136 List<uint8_t>* one_byte_buffer,
138 List<uc16>* two_byte_buffer) { 137 List<uc16>* two_byte_buffer) {
139 DisallowHeapAllocation no_gc; 138 DisallowHeapAllocation no_gc;
140 String::FlatContent uri_content = uri->GetFlatContent(); 139 String::FlatContent uri_content = uri->GetFlatContent();
141 140
142 int uri_length = uri->length(); 141 int uri_length = uri->length();
143 for (int k = 0; k < uri_length; k++) { 142 for (int k = 0; k < uri_length; k++) {
144 uc16 code = uri_content.Get(k); 143 uc16 code = uri_content.Get(k);
145 if (code == '%') { 144 if (code == '%') {
146 uc16 decoded; 145 int two_digits;
147 if (k + 2 >= uri_length || 146 if (k + 2 >= uri_length ||
148 (decoded = TwoDigitHex(uri_content.Get(k + 1), 147 (two_digits = TwoDigitHex(uri_content.Get(k + 1),
149 uri_content.Get(k + 2))) < 0) { 148 uri_content.Get(k + 2))) < 0) {
150 return false; 149 return false;
151 } 150 }
152 151
152 uc16 decoded = static_cast<uc16>(two_digits);
153 if (decoded > unibrow::Utf8::kMaxOneByteChar) { 153 if (decoded > unibrow::Utf8::kMaxOneByteChar) {
154 return IntoTwoByte(k, is_uri, uri_length, &uri_content, 154 return IntoTwoByte(k, is_uri, uri_length, &uri_content,
155 two_byte_buffer); 155 two_byte_buffer);
156 } 156 }
157 157
158 AddToBuffer(decoded, &uri_content, k, is_uri, one_byte_buffer); 158 AddToBuffer(decoded, &uri_content, k, is_uri, one_byte_buffer);
159 k += 2; 159 k += 2;
160 } else { 160 } else {
161 if (code > unibrow::Utf8::kMaxOneByteChar) { 161 if (code > unibrow::Utf8::kMaxOneByteChar) {
162 return IntoTwoByte(k, is_uri, uri_length, &uri_content, 162 return IntoTwoByte(k, is_uri, uri_length, &uri_content,
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 MaybeHandle<String> Uri::Unescape(Isolate* isolate, Handle<String> string) { 496 MaybeHandle<String> Uri::Unescape(Isolate* isolate, Handle<String> string) {
497 Handle<String> result; 497 Handle<String> result;
498 string = String::Flatten(string); 498 string = String::Flatten(string);
499 return string->IsOneByteRepresentationUnderneath() 499 return string->IsOneByteRepresentationUnderneath()
500 ? UnescapePrivate<uint8_t>(isolate, string) 500 ? UnescapePrivate<uint8_t>(isolate, string)
501 : UnescapePrivate<uc16>(isolate, string); 501 : UnescapePrivate<uc16>(isolate, string);
502 } 502 }
503 503
504 } // namespace internal 504 } // namespace internal
505 } // namespace v8 505 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/scanner.h ('k') | test/cctest/interpreter/test-source-positions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698