Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/853#discussion_r13000834
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -1166,4 +1166,42 @@ private[spark] object Utils extends Logging {
             true
         }
       }
    +
    +  /**
    +   * Return a well-formed URI for the file described by a user input 
string.
    +   *
    +   * If the supplied path does not contain a scheme, or is a relative 
path, it will be
    +   * converted into an absolute path with a file:// scheme.
    +   */
    +  def resolveURI(path: String, testWindows: Boolean = false): URI = {
    +
    +    val windows = isWindows || testWindows
    +    // In Windows, the file separator is a backslash, but this is 
inconsistent with the URI format
    +    val formattedPath = if (windows) path.replace("\\", "/") else path
    +    // Each Windows drive contains only a single alphabet character
    +    val windowsDrive = "([a-zA-Z])".r
    +
    +    val uri = new URI(formattedPath)
    +    uri.getScheme match {
    --- End diff --
    
    Can you also add a validation check here to ensure that the URI (and hence 
the original path given by the user) is valid and not malformed. I, just for 
fun, entered "file:hello", and it gave me a NPE at a random location. 



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to