Fix StringIndexOutOfBoundsException on /register with URL prefix
HttpServletRequest#getPathInfo() raises StringIndexOutOfBoundsException when the path was not set. Add a pattern to detect this and don't attempt to call getPathInfo(). Bug: Issue 6205 Change-Id: If21d8cbebbedfc1d1aa1d12aee295d5a55d9da41
This commit is contained in:
		
				
					committed by
					
						
						David Pursehouse
					
				
			
			
				
	
			
			
			
						parent
						
							da7a5ca0e6
						
					
				
				
					commit
					aaaf45089a
				
			@@ -88,7 +88,8 @@ class UrlModule extends ServletModule {
 | 
			
		||||
    serve("/starred").with(query("is:starred"));
 | 
			
		||||
 | 
			
		||||
    serveRegex("^/settings/?$").with(screen(PageLinks.SETTINGS));
 | 
			
		||||
    serveRegex("^/register(/.*)?$").with(registerScreen());
 | 
			
		||||
    serveRegex("^/register$").with(registerScreen(false));
 | 
			
		||||
    serveRegex("^/register/(.+)$").with(registerScreen(true));
 | 
			
		||||
    serveRegex("^/([1-9][0-9]*)/?$").with(directChangeById());
 | 
			
		||||
    serveRegex("^/p/(.*)$").with(queryProjectNew());
 | 
			
		||||
    serveRegex("^/r/(.+)/?$").with(DirectChangeByCommit.class);
 | 
			
		||||
@@ -251,7 +252,7 @@ class UrlModule extends ServletModule {
 | 
			
		||||
    return srv;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  private Key<HttpServlet> registerScreen() {
 | 
			
		||||
  private Key<HttpServlet> registerScreen(final Boolean slash) {
 | 
			
		||||
    return key(
 | 
			
		||||
        new HttpServlet() {
 | 
			
		||||
          private static final long serialVersionUID = 1L;
 | 
			
		||||
@@ -259,7 +260,8 @@ class UrlModule extends ServletModule {
 | 
			
		||||
          @Override
 | 
			
		||||
          protected void doGet(final HttpServletRequest req, final HttpServletResponse rsp)
 | 
			
		||||
              throws IOException {
 | 
			
		||||
            toGerrit("/register" + req.getPathInfo(), req, rsp);
 | 
			
		||||
            String path = String.format("/register%s", slash ? req.getPathInfo() : "");
 | 
			
		||||
            toGerrit(path, req, rsp);
 | 
			
		||||
          }
 | 
			
		||||
        });
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user