COMMON: Do not crash on attempt to punyencode empty strings
This commit is contained in:
parent
136d1b23c0
commit
9fcb33a5e6
1 changed files with 6 additions and 0 deletions
|
@ -132,6 +132,9 @@ String punycode_encode(const U32String &src) {
|
||||||
size_t h = 0, si;
|
size_t h = 0, si;
|
||||||
String dst = "xn--";
|
String dst = "xn--";
|
||||||
|
|
||||||
|
if (!srclen)
|
||||||
|
return src;
|
||||||
|
|
||||||
for (si = 0; si < srclen; si++) {
|
for (si = 0; si < srclen; si++) {
|
||||||
if (src[si] < 128) {
|
if (src[si] < 128) {
|
||||||
dst += src[si];
|
dst += src[si];
|
||||||
|
@ -204,6 +207,9 @@ bool punycode_hasprefix(const String &src) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool punycode_needEncode(const String &src) {
|
bool punycode_needEncode(const String &src) {
|
||||||
|
if (!src.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
for (uint si = 0; si < src.size(); si++) {
|
for (uint si = 0; si < src.size(); si++) {
|
||||||
if (src[si] & 0x80 || src[si] < 0x20 || strchr(SPECIAL_SYMBOLS, src[si])) {
|
if (src[si] & 0x80 || src[si] < 0x20 || strchr(SPECIAL_SYMBOLS, src[si])) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue