Skip to content

Commit

Permalink
Merge pull request #380 from peter-janssen/expand-allowed-repository-…
Browse files Browse the repository at this point in the history
…id-chars

Expand allowed maven repository id characters to match maven
  • Loading branch information
eed3si9n committed Jun 2, 2021
2 parents f461546 + 976ff44 commit 564119c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 564119c

Please sign in to comment.