You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/07/31 17:53:05 UTC

[GitHub] [spark] zsxwing commented on a change in pull request #29271: [SPARK-32467][UI]Avoid encoding URL twice on https redirect

zsxwing commented on a change in pull request #29271:
URL: https://github.com/apache/spark/pull/29271#discussion_r463749136



##########
File path: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala
##########
@@ -440,16 +439,34 @@ private[spark] object JettyUtils extends Logging {
     handler.addFilter(holder, "/*", EnumSet.allOf(classOf[DispatcherType]))
   }
 
+  private def decodeURL(url: String, encoding: String): String = {
+    if (url == null) {
+      null
+    } else {
+      URLDecoder.decode(url, encoding)
+    }
+  }
+
   // Create a new URI from the arguments, handling IPv6 host encoding and default ports.
-  private def createRedirectURI(
-      scheme: String, server: String, port: Int, path: String, query: String) = {
+  private def createRedirectURI(scheme: String, port: Int, request: Request): String = {
+    val server = request.getServerName
     val redirectServer = if (server.contains(":") && !server.startsWith("[")) {
       s"[${server}]"
     } else {
       server
     }
     val authority = s"$redirectServer:$port"
-    new URI(scheme, authority, path, query, null).toString
+    val queryEncoding = if (request.getQueryEncoding != null) {

Review comment:
       > I tried but it doesn't do the decoding with URI.toString
   
   URI.toString doesn't do the decoding. It will encode characters if necessary. For example,
   
   ```
   scala> val uri = new java.net.URI(null, null, "foo bar", "foo bar", null).toString
   uri: String = foo%20bar?foo%20bar
   ```
   
   Anyway, this doesn't matter. I tried to consolidate these two method but it didn't look better.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org