Escape semicolon route playframework 2.0.2

僤鯓⒐⒋嵵緔 提交于 2020-01-05 07:27:22

问题


I would like to do a redirect function with playframework. So far I have this in my routes

GET     /redirect            com.test.redirect(redirecturl: String?="")

and my controller :

public static Result redirect(String redirecturl) { 
   return redirect(redirectURL); 
}

This is working well but I have a problem when I pass a url containing a semicolon ";"

If I go to

http:localhost:9000/redirect?redirecturl=http://www.google.com;testaftersemicolon

It redirect me to google.com but in my log the redirecturl is only equals to "http://www.google.com" stopping after a semicolon.

Is there a way to escape it ? Or to do a custom routing inside play?


回答1:


You should be able to escape it by using a custom regular expression in the routes file. This is described in the documentation about routing. Basically something like the following should work:

GET     /redirect/$url<.+>            com.test.redirect(url: String?="")


来源:https://stackoverflow.com/questions/11967290/escape-semicolon-route-playframework-2-0-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!