Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SI-6194, repl crash.

Always a bad idea to use replaceAll on unknown strings,
as we saw here when windows classpaths arrived containing
escape-requiring backslashes.
  • Loading branch information...
commit ac61e341216c2c61e29c74a8c3c27e915d479925 1 parent 1284c3c
Paul Phillips paulp authored
8 src/compiler/scala/tools/nsc/util/ClassPath.scala
View
@@ -15,6 +15,7 @@ import scala.reflect.ClassTag
import Jar.isJarOrZip
import File.pathSeparator
import java.net.MalformedURLException
+import java.util.regex.PatternSyntaxException
/** <p>
* This module provides star expansion of '-classpath' option arguments, behaves the same as
@@ -39,8 +40,11 @@ object ClassPath {
if (pattern == "*") lsDir(Directory("."))
else if (pattern endsWith wildSuffix) lsDir(Directory(pattern dropRight 2))
else if (pattern contains '*') {
- val regexp = ("^%s$" format pattern.replaceAll("""\*""", """.*""")).r
- lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined)
+ try {
+ val regexp = ("^" + pattern.replaceAllLiterally("""\*""", """.*""") + "$").r
+ lsDir(Directory(pattern).parent, regexp findFirstIn _ isDefined)
+ }
+ catch { case _: PatternSyntaxException => List(pattern) }
}
else List(pattern)
}
1  test/files/run/t6194.check
View
@@ -0,0 +1 @@
+C:\FooBar\Java\includes\*.jar
8 test/files/run/t6194.scala
View
@@ -0,0 +1,8 @@
+import scala.tools.nsc.util._
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val cp = ClassPath.expandPath("""C:\FooBar\Java\includes\*.jar""") mkString java.io.File.pathSeparator
+ println(cp)
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.