Fixed HTTP Response splitting problem.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3444 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2007-06-15 02:01:46 +00:00
1 parent bfb1f246ee
commit d893c87400
2 files changed
+15 -2

No files matched your search

+8 -2
View File
@@ -74,6 +74,7 @@ import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeSet;
import java.util.Vector;
import java.util.regex.Pattern;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.LogRecord;
@@ -1436,8 +1437,11 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
/**
* Changes the icon size by changing the cookie
*/
public void doIconSize( StaplerRequest req, StaplerResponse rsp ) throws IOException {
rsp.addCookie(new Cookie("iconSize",req.getQueryString()));
public void doIconSize( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
String qs = req.getQueryString();
if(!ICON_SIZE.matcher(qs).matches())
throw new ServletException();
rsp.addCookie(new Cookie("iconSize", qs));
String ref = req.getHeader("Referer");
if(ref==null) ref=".";
rsp.sendRedirect2(ref);
@@ -1652,6 +1656,8 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node
private static final Logger LOGGER = Logger.getLogger(Hudson.class.getName());
private static final Pattern ICON_SIZE = Pattern.compile("\\d+x\\d+");
static {
XSTREAM.alias("hudson",Hudson.class);
XSTREAM.alias("slave",Slave.class);
+7
View File
@@ -514,6 +514,13 @@ public abstract class Job<JobT extends Job<JobT,RunT>, RunT extends Run<JobT,Run
String newName = req.getParameter("name");
if(newName!=null && !newName.equals(name)) {
// check this error early to avoid HTTP response splitting.
try {
Hudson.checkGoodName(newName);
} catch (ParseException e) {
sendError(e,req,rsp);
return;
}
rsp.sendRedirect("rename?newName="+newName);
} else {
rsp.sendRedirect(".");