Merge pull request #380 from peter-janssen/expand-allowed-repository-id-chars

Expand allowed maven repository id characters to match maven
This commit is contained in:
eugene yokota 2021-06-02 15:17:10 -04:00 committed by GitHub
commit 564119c404
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -504,7 +504,7 @@ class MakePom(val log: Logger) {
s.toArray.map(_.asInstanceOf[DependencyResolver])
def toID(name: String) = checkID(name.filter(isValidIDCharacter).mkString, name)
def isValidIDCharacter(c: Char) = c.isLetterOrDigit
def isValidIDCharacter(c: Char) = !"""\/:"<>|?*""".contains(c)
private def checkID(id: String, name: String) =
if (id.isEmpty) sys.error("Could not convert '" + name + "' to an ID") else id
def mavenRepository(repo: MavenRepository): XNode =

View File

@ -1,6 +1,7 @@
package sbt.internal.librarymanagement
import sbt.internal.util.ConsoleLogger
import sbt.librarymanagement.MavenRepository
import verify.BasicTestSuite
// http://ant.apache.org/ivy/history/2.3.0/ivyfile/dependency.html
@ -74,6 +75,18 @@ object MakePomSpec extends BasicTestSuite {
beParsedAsError("foo+")
}
test("repository id should not contain maven illegal repo id characters") {
val repository = mp.mavenRepository(
MavenRepository(
"""repository-id-\with-/illegal:"<-chars>|?*-others~!@#$%^&`';{}[]=+_,.""",
"uri"
)
)
assert(
(repository \ "id").text == "repository-id-with-illegal-chars-others~!@#$%^&`';{}[]=+_,."
)
}
val mp = new MakePom(ConsoleLogger())
def convertTo(s: String, expected: String): Unit = {
assert(MakePom.makeDependencyVersion(s) == expected)