package textapp.server

import scala.io.Source
import java.io.InputStream
import java.net.URLDecoder

class FormDecoder(inputStream: InputStream) {
  private val source = Source.fromInputStream(inputStream)
  private val sourceAsString = source.getLines.toList.foldLeft("")(_+_)
  private val paramArray = sourceAsString.split("&").filter(_ != "").map(_.split("=")).map { kvPair =>
    if (kvPair.size != 2) throw new RuntimeException("Invalid key-value pair in '%s'".format(kvPair.mkString("=")))
    val (encodedKey, encodedValue) = (kvPair(0), kvPair(1))
    val key = URLDecoder.decode(encodedKey, "UTF-8")
    val value = URLDecoder.decode(encodedValue, "UTF-8")
    (key, value)
  }
  val params = Map(paramArray: _*)
}


package textapp.server

import scala.io.Source
import java.io.InputStream
import java.net.URLDecoder

class FormDecoder(inputStream: InputStream) {
  private val source = Source.fromInputStream(inputStream)
  private val sourceAsString = source.getLines.toList.foldLeft("")(_+_)
  private val paramArray = sourceAsString.split("&").filter(_ != "").map(_.split("=")).map { kvPair =>
    if (kvPair.size != 2) throw new RuntimeException("Invalid key-value pair in '%s'".format(kvPair.mkString("=")))
    val (encodedKey, encodedValue) = (kvPair(0), kvPair(1))
    val key = URLDecoder.decode(encodedKey)
    val value = URLDecoder.decode(encodedValue)
    (key, value)
  }
  val params = Map(paramArray: _*)
}


--- 
+++ 
@@ -10,8 +10,8 @@
   private val paramArray = sourceAsString.split("&").filter(_ != "").map(_.split("=")).map { kvPair =>
     if (kvPair.size != 2) throw new RuntimeException("Invalid key-value pair in '%s'".format(kvPair.mkString("=")))
     val (encodedKey, encodedValue) = (kvPair(0), kvPair(1))
-    val key = URLDecoder.decode(encodedKey)
-    val value = URLDecoder.decode(encodedValue)
+    val key = URLDecoder.decode(encodedKey, "UTF-8")
+    val value = URLDecoder.decode(encodedValue, "UTF-8")
     (key, value)
   }
   val params = Map(paramArray: _*)
Remove call to deprecated decode by giving explicit encoding

Signed-off-by: Sami Rosendahl <b33c757bb777642ab0d59c699f8d5782929a814f@reaktor.fi>
Signed-off-by: Antti Mattila <422fa99ecc9af171a83eb3d69d51885324be22a3@reaktor.fi>
Acked-by: Aki Saarinen <2c8035bb80cf98a391872dcbe797b269d759f6d9@reaktor.fi>
