From ac61e341216c2c61e29c74a8c3c27e915d479925 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 27 Dec 2012 11:41:22 -0800 Subject: 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. --- src/compiler/scala/tools/nsc/util/ClassPath.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') 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 /**

* 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) } -- cgit v1.2.3