[build] Encode URL parts to escape HTML chars for build-index

This commit is contained in:
Him188 2023-03-19 15:03:23 +00:00
parent 43b5e710ef
commit 9b86d3be8f
No known key found for this signature in database
GPG Key ID: BA439CDDCF652375

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Mamoe Technologies and contributors.
* Copyright 2019-2023 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@ -52,7 +52,8 @@ suspend fun HttpClient.getExistingIndex(
commitRef: String,
): Index? {
// https://build.mirai.mamoe.net/v1/mirai-core/dev/indexes/?commitRef=29121565132bed6e996f3de32faaf49106ae8e39
val resp = get("https://build.mirai.mamoe.net/v1/$module/$branch/indexes/") {
val resp =
get("https://build.mirai.mamoe.net/v1/${module.encodeURLPathPart()}/${branch.encodeURLPathPart()}/indexes/") {
basicAuth(
System.getenv("mirai.build.index.auth.username"),
System.getenv("mirai.build.index.auth.password")
@ -74,7 +75,7 @@ suspend fun HttpClient.createBranch(
branch: String,
): Boolean {
// https://build.mirai.mamoe.net/v1/mirai-core/dev/indexes/?commitRef=29121565132bed6e996f3de32faaf49106ae8e39
val resp = put("https://build.mirai.mamoe.net/v1/$module/$branch") {
val resp = put("https://build.mirai.mamoe.net/v1/${module.encodeURLPathPart()}/${branch.encodeURLPathPart()}") {
basicAuth(
System.getenv("mirai.build.index.auth.username"),
System.getenv("mirai.build.index.auth.password")
@ -88,7 +89,8 @@ suspend fun HttpClient.postNextIndex(
branch: String,
commitRef: String,
): Index {
val resp = post("https://build.mirai.mamoe.net/v1/$module/$branch/indexes/next") {
val resp =
post("https://build.mirai.mamoe.net/v1/${module.encodeURLPathPart()}/${branch.encodeURLPathPart()}/indexes/next") {
basicAuth(
System.getenv("mirai.build.index.auth.username"),
System.getenv("mirai.build.index.auth.password")