summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/util/ClassPath.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-12-27 11:41:22 -0800
committerPaul Phillips <paulp@improving.org>2012-12-27 11:48:54 -0800
commitac61e341216c2c61e29c74a8c3c27e915d479925 (patch)
tree4b429f319ce2287b33647a1c8f90947779785f16 /src/compiler/scala/tools/nsc/util/ClassPath.scala
parent1284c3c6f38cc419a0a39fd68b3d5cf81b36b1a5 (diff)
downloadscala-ac61e341216c2c61e29c74a8c3c27e915d479925.tar.gz
scala-ac61e341216c2c61e29c74a8c3c27e915d479925.tar.bz2
scala-ac61e341216c2c61e29c74a8c3c27e915d479925.zip
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.
Diffstat (limited to 'src/compiler/scala/tools/nsc/util/ClassPath.scala')
-rw-r--r--src/compiler/scala/tools/nsc/util/ClassPath.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala
index 8732e06502..471e2653cf 100644
--- a/src/compiler/scala/tools/nsc/util/ClassPath.scala
+++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala
@@ -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)
}