OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2008 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/base/urlencode.h" | 11 #include "webrtc/base/urlencode.h" |
12 | 12 |
13 #include "webrtc/base/common.h" | 13 #include "webrtc/base/checks.h" |
14 #include "webrtc/base/stringutils.h" | 14 #include "webrtc/base/stringutils.h" |
15 | 15 |
16 static int HexPairValue(const char * code) { | 16 static int HexPairValue(const char * code) { |
17 int value = 0; | 17 int value = 0; |
18 for (const char * pch = code; pch < code + 2; ++pch) { | 18 for (const char * pch = code; pch < code + 2; ++pch) { |
19 value <<= 4; | 19 value <<= 4; |
20 int digit = *pch; | 20 int digit = *pch; |
21 if (digit >= '0' && digit <= '9') { | 21 if (digit >= '0' && digit <= '9') { |
22 value += digit - '0'; | 22 value += digit - '0'; |
23 } | 23 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
107 } else { | 107 } else { |
108 if (static_cast<unsigned>(dest - start) + 4 > max) { | 108 if (static_cast<unsigned>(dest - start) + 4 > max) { |
109 break; | 109 break; |
110 } | 110 } |
111 *dest++ = '%'; | 111 *dest++ = '%'; |
112 *dest++ = digits[(ch >> 4) & 0x0F]; | 112 *dest++ = digits[(ch >> 4) & 0x0F]; |
113 *dest++ = digits[ ch & 0x0F]; | 113 *dest++ = digits[ ch & 0x0F]; |
114 } | 114 } |
115 source++; | 115 source++; |
116 } | 116 } |
117 ASSERT(static_cast<unsigned int>(dest - start) < max); | 117 RTC_DCHECK(static_cast<unsigned int>(dest - start) < max); |
palmkvist
2016/12/01 13:31:13
RTC_DCHECK_LT
Hzj_jie
2016/12/06 22:33:07
Done.
| |
118 *dest = 0; | 118 *dest = 0; |
119 | 119 |
120 return static_cast<int>(dest - start); | 120 return static_cast<int>(dest - start); |
121 } | 121 } |
122 | 122 |
123 int UrlEncode(const char *source, char *dest, unsigned max) { | 123 int UrlEncode(const char *source, char *dest, unsigned max) { |
124 return InternalUrlEncode(source, dest, max, true, false); | 124 return InternalUrlEncode(source, dest, max, true, false); |
125 } | 125 } |
126 | 126 |
127 int UrlEncodeWithoutEncodingSpaceAsPlus(const char *source, char *dest, | 127 int UrlEncodeWithoutEncodingSpaceAsPlus(const char *source, char *dest, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 UrlEncodeStringWithoutEncodingSpaceAsPlus(const std::string & decoded) { | 172 UrlEncodeStringWithoutEncodingSpaceAsPlus(const std::string & decoded) { |
173 return InternalUrlEncodeString(decoded, false, false); | 173 return InternalUrlEncodeString(decoded, false, false); |
174 } | 174 } |
175 | 175 |
176 std::string | 176 std::string |
177 UrlEncodeStringForOnlyUnsafeChars(const std::string & decoded) { | 177 UrlEncodeStringForOnlyUnsafeChars(const std::string & decoded) { |
178 return InternalUrlEncodeString(decoded, false, true); | 178 return InternalUrlEncodeString(decoded, false, true); |
179 } | 179 } |
180 | 180 |
181 } // namespace rtc | 181 } // namespace rtc |
OLD | NEW |