diff options
author | Kousuke Saruta <sarutak@oss.nttdata.co.jp> | 2014-10-24 13:08:21 -0700 |
---|---|---|
committer | Andrew Or <andrew@databricks.com> | 2014-10-24 13:09:08 -0700 |
commit | 80dde80a6d4f07d521dfeb471c425a67811504d9 (patch) | |
tree | a53e34d78e643feadf14fa738d8e853582e34bda /core/src/main | |
parent | 386fc46bc039714fdfcf3db679f689287f8ef836 (diff) | |
download | spark-80dde80a6d4f07d521dfeb471c425a67811504d9.tar.gz spark-80dde80a6d4f07d521dfeb471c425a67811504d9.tar.bz2 spark-80dde80a6d4f07d521dfeb471c425a67811504d9.zip |
[SPARK-4075] [Deploy] Jar url validation is not enough for Jar file
In deploy.ClientArguments.isValidJarUrl, the url is checked as follows.
def isValidJarUrl(s: String): Boolean = s.matches("(.+):(.+)jar")
So, it allows like 'hdfs:file.jar' (no authority).
Author: Kousuke Saruta <sarutak@oss.nttdata.co.jp>
Closes #2925 from sarutak/uri-syntax-check-improvement and squashes the following commits:
cf06173 [Kousuke Saruta] Improved URI syntax checking
(cherry picked from commit 098f83c7ccd7dad9f9228596da69fe5f55711a52)
Signed-off-by: Andrew Or <andrew@databricks.com>
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/org/apache/spark/deploy/ClientArguments.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/core/src/main/scala/org/apache/spark/deploy/ClientArguments.scala b/core/src/main/scala/org/apache/spark/deploy/ClientArguments.scala index 39150deab8..4e802e02c4 100644 --- a/core/src/main/scala/org/apache/spark/deploy/ClientArguments.scala +++ b/core/src/main/scala/org/apache/spark/deploy/ClientArguments.scala @@ -17,6 +17,8 @@ package org.apache.spark.deploy +import java.net.{URI, URISyntaxException} + import scala.collection.mutable.ListBuffer import org.apache.log4j.Level @@ -114,5 +116,12 @@ private[spark] class ClientArguments(args: Array[String]) { } object ClientArguments { - def isValidJarUrl(s: String): Boolean = s.matches("(.+):(.+)jar") + def isValidJarUrl(s: String): Boolean = { + try { + val uri = new URI(s) + uri.getScheme != null && uri.getAuthority != null && s.endsWith("jar") + } catch { + case _: URISyntaxException => false + } + } } |