Merge branch 'master' into refactor/split_lib_app
This commit is contained in:
commit
231bca79fb
1 changed files with 21 additions and 17 deletions
|
@ -59,7 +59,7 @@ object UrlEncoderUtil {
|
||||||
// see https://www.rfc-editor.org/rfc/rfc3986#page-13
|
// see https://www.rfc-editor.org/rfc/rfc3986#page-13
|
||||||
// and https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set
|
// and https://url.spec.whatwg.org/#application-x-www-form-urlencoded-percent-encode-set
|
||||||
private fun Char.isUnreserved(): Boolean {
|
private fun Char.isUnreserved(): Boolean {
|
||||||
return this <= 'z' && unreservedChars.get(code)
|
return this <= 'z' && unreservedChars[code]
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun StringBuilder.appendEncodedDigit(digit: Int) {
|
private fun StringBuilder.appendEncodedDigit(digit: Int) {
|
||||||
|
@ -165,25 +165,29 @@ object UrlEncoderUtil {
|
||||||
out.append(source, 0, i)
|
out.append(source, 0, i)
|
||||||
}
|
}
|
||||||
val cp = source.codePointAt(i)
|
val cp = source.codePointAt(i)
|
||||||
if (cp < 0x80) {
|
when {
|
||||||
if (spaceToPlus && ch == ' ') {
|
cp < 0x80 -> {
|
||||||
out.append('+')
|
if (spaceToPlus && ch == ' ') {
|
||||||
} else {
|
out.append('+')
|
||||||
out.appendEncodedByte(cp)
|
} else {
|
||||||
|
out.appendEncodedByte(cp)
|
||||||
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
i++
|
Character.isBmpCodePoint(cp) -> {
|
||||||
} else if (Character.isBmpCodePoint(cp)) {
|
for (b in ch.toString().toByteArray(StandardCharsets.UTF_8)) {
|
||||||
for (b in ch.toString().toByteArray(StandardCharsets.UTF_8)) {
|
out.appendEncodedByte(b.toInt())
|
||||||
out.appendEncodedByte(b.toInt())
|
}
|
||||||
|
i++
|
||||||
}
|
}
|
||||||
i++
|
Character.isSupplementaryCodePoint(cp) -> {
|
||||||
} else if (Character.isSupplementaryCodePoint(cp)) {
|
val high = Character.highSurrogate(cp)
|
||||||
val high = Character.highSurrogate(cp)
|
val low = Character.lowSurrogate(cp)
|
||||||
val low = Character.lowSurrogate(cp)
|
for (b in charArrayOf(high, low).concatToString().toByteArray(StandardCharsets.UTF_8)) {
|
||||||
for (b in charArrayOf(high, low).concatToString().toByteArray(StandardCharsets.UTF_8)) {
|
out.appendEncodedByte(b.toInt())
|
||||||
out.appendEncodedByte(b.toInt())
|
}
|
||||||
|
i += 2
|
||||||
}
|
}
|
||||||
i += 2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue