Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand allowed maven repository id characters to match maven #380

Merged
merged 2 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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