Program: 69961
Project: 69961
Buggy source:
public void execute(HttpServletRequest request,HttpServletResponse response,String uriPrefix){
  final String origUri=request.getRequestURI();
  String restPart=origUri.substring(uriPrefix.length());
  try {
    restPart=URLDecoder.decode(restPart,"String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    log.error("String_Node_Str",e);
  }
  String[] split=restPart.split("String_Node_Str");
  if (split.length % 2 != 0) {
    DispatcherAction.sendBadRequest(origUri,response);
    log.warn("String_Node_Str" + restPart);
    return;
  }
  String businessPath="String_Node_Str";
  for (int i=0; i < split.length; i=i + 2) {
    String key=split[i];
    if (key != null && key.startsWith("String_Node_Str")) {
      key=key.replace("String_Node_Str","String_Node_Str");
    }
    String value=split[i + 1];
    businessPath+="String_Node_Str" + key + "String_Node_Str"+ value+ "String_Node_Str";
  }
  if (log.isDebug()) {
    log.debug("String_Node_Str" + origUri);
    log.debug("String_Node_Str" + restPart);
    log.debug("String_Node_Str" + businessPath);
  }
  try {
    BusinessControl bc=BusinessControlFactory.getInstance().createFromString(businessPath);
    if (!bc.hasContextEntry()) {
      DispatcherAction.sendBadRequest(origUri,response);
      return;
    }
  }
 catch (  Exception e) {
    DispatcherAction.sendBadRequest(origUri,response);
    log.warn("String_Node_Str" + origUri,e);
    return;
  }
  UserSession usess=UserSession.getUserSession(request);
  UserRequest ureq=null;
  try {
    ureq=new UserRequest(uriPrefix,request,response);
  }
 catch (  NumberFormatException nfe) {
    if (log.isDebug()) {
      log.debug("String_Node_Str" + request.getPathInfo());
    }
    DispatcherAction.sendBadRequest(request.getPathInfo(),response);
    return;
  }
  String xOlatToken=ureq.getParameter(RestSecurityHelper.SEC_TOKEN);
  if (xOlatToken != null) {
    RestSecurityBean securityBean=(RestSecurityBean)CoreSpringFactory.getBean(RestSecurityBean.class);
    Identity restIdentity=securityBean.getIdentity(xOlatToken);
    if (log.isDebug()) {
      if (restIdentity == null)       log.debug("String_Node_Str" + RestSecurityHelper.SEC_TOKEN + "String_Node_Str");
 else       log.debug("String_Node_Str" + RestSecurityHelper.SEC_TOKEN + "String_Node_Str"+ restIdentity.getName());
    }
    if (restIdentity != null) {
      if (!usess.isAuthenticated() || !restIdentity.equalsByPersistableKey(usess.getIdentity())) {
        int loginStatus=AuthHelper.doLogin(restIdentity,RestSecurityHelper.SEC_TOKEN,ureq);
        if (loginStatus == AuthHelper.LOGIN_OK) {
          UserDeletionManager.getInstance().setIdentityAsActiv(restIdentity);
        }
 else {
          DispatcherAction.redirectToDefaultDispatcher(response);
        }
      }
 else       if (Windows.getWindows(usess).getAttribute("String_Node_Str") == null) {
        AuthHelper.createAuthHome(ureq);
      }
    }
  }
  boolean auth=usess.isAuthenticated();
  if (auth) {
    setBusinessPathInUserSession(usess,businessPath);
    if (Windows.getWindows(usess).getAttribute("String_Node_Str") == null) {
      AuthHelper.createAuthHome(ureq);
      String url=getRedirectToURL(usess) + "String_Node_Str" + usess.getSessionInfo().getSession().getId();
      DispatcherAction.redirectTo(response,url);
    }
 else {
      String url=getRedirectToURL(usess);
      DispatcherAction.redirectTo(response,url);
    }
  }
 else {
    setBusinessPathInUserSession(usess,businessPath);
    String invitationAccess=ureq.getParameter(AuthenticatedDispatcher.INVITATION);
    if (invitationAccess != null && LoginModule.isInvitationEnabled()) {
      Locale guestLoc=getLang(ureq);
      int loginStatus=AuthHelper.doInvitationLogin(invitationAccess,ureq,guestLoc);
      if (loginStatus == AuthHelper.LOGIN_OK) {
        Identity invite=usess.getIdentity();
        UserDeletionManager.getInstance().setIdentityAsActiv(invite);
        String url=getRedirectToURL(usess);
        DispatcherAction.redirectTo(response,url);
      }
 else       if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
        DispatcherAction.redirectToServiceNotAvailable(response);
      }
 else {
        DispatcherAction.redirectToDefaultDispatcher(response);
      }
    }
 else {
      String guestAccess=ureq.getParameter(AuthenticatedDispatcher.GUEST);
      if (guestAccess == null || !LoginModule.isGuestLoginLinksEnabled()) {
        DispatcherAction.redirectToDefaultDispatcher(response);
        return;
      }
 else       if (guestAccess.equals(AuthenticatedDispatcher.TRUE)) {
        Locale guestLoc=getLang(ureq);
        int loginStatus=AuthHelper.doAnonymousLogin(ureq,guestLoc);
        if (loginStatus == AuthHelper.LOGIN_OK) {
          String url=getRedirectToURL(usess);
          DispatcherAction.redirectTo(response,url);
        }
 else         if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
          DispatcherAction.redirectToServiceNotAvailable(response);
        }
 else {
          DispatcherAction.redirectToDefaultDispatcher(response);
        }
      }
    }
  }
}

Fixed version (ground truth):
public void execute(HttpServletRequest request,HttpServletResponse response,String uriPrefix){
  final String origUri=request.getRequestURI();
  String restPart=origUri.substring(uriPrefix.length());
  try {
    restPart=URLDecoder.decode(restPart,"String_Node_Str");
  }
 catch (  UnsupportedEncodingException e) {
    log.error("String_Node_Str",e);
  }
  String[] split=restPart.split("String_Node_Str");
  if (split.length % 2 != 0) {
    DispatcherAction.sendBadRequest(origUri,response);
    log.warn("String_Node_Str" + restPart);
    return;
  }
  String businessPath="String_Node_Str";
  for (int i=0; i < split.length; i=i + 2) {
    String key=split[i];
    if (key != null && key.startsWith("String_Node_Str")) {
      key=key.replace("String_Node_Str","String_Node_Str");
    }
    String value=split[i + 1];
    businessPath+="String_Node_Str" + key + "String_Node_Str"+ value+ "String_Node_Str";
  }
  if (log.isDebug()) {
    log.debug("String_Node_Str" + origUri);
    log.debug("String_Node_Str" + restPart);
    log.debug("String_Node_Str" + businessPath);
  }
  try {
    BusinessControl bc=BusinessControlFactory.getInstance().createFromString(businessPath);
    if (!bc.hasContextEntry()) {
      DispatcherAction.sendBadRequest(origUri,response);
      return;
    }
  }
 catch (  Exception e) {
    DispatcherAction.sendBadRequest(origUri,response);
    log.warn("String_Node_Str" + origUri,e);
    return;
  }
  UserSession usess=UserSession.getUserSession(request);
  UserRequest ureq=null;
  try {
    ureq=new UserRequest(uriPrefix,request,response);
  }
 catch (  NumberFormatException nfe) {
    if (log.isDebug()) {
      log.debug("String_Node_Str" + request.getPathInfo());
    }
    DispatcherAction.sendBadRequest(request.getPathInfo(),response);
    return;
  }
  String xOlatToken=ureq.getParameter(RestSecurityHelper.SEC_TOKEN);
  if (xOlatToken != null) {
    RestSecurityBean securityBean=(RestSecurityBean)CoreSpringFactory.getBean(RestSecurityBean.class);
    Identity restIdentity=securityBean.getIdentity(xOlatToken);
    if (log.isDebug()) {
      if (restIdentity == null)       log.debug("String_Node_Str" + RestSecurityHelper.SEC_TOKEN + "String_Node_Str");
 else       log.debug("String_Node_Str" + RestSecurityHelper.SEC_TOKEN + "String_Node_Str"+ restIdentity.getName());
    }
    if (restIdentity != null) {
      if (!usess.isAuthenticated() || !restIdentity.equalsByPersistableKey(usess.getIdentity())) {
        int loginStatus=AuthHelper.doLogin(restIdentity,RestSecurityHelper.SEC_TOKEN,ureq);
        if (loginStatus == AuthHelper.LOGIN_OK) {
          UserDeletionManager.getInstance().setIdentityAsActiv(restIdentity);
        }
 else {
          DispatcherAction.redirectToDefaultDispatcher(response);
        }
      }
 else       if (Windows.getWindows(usess).getAttribute("String_Node_Str") == null) {
        Window currentWindow=AuthHelper.createAuthHome(ureq).getWindow();
        currentWindow.setUriPrefix(WebappHelper.getServletContextPath() + DispatcherAction.PATH_AUTHENTICATED);
        Windows ws=Windows.getWindows(ureq);
        ws.registerWindow(currentWindow);
      }
    }
  }
  boolean auth=usess.isAuthenticated();
  if (auth) {
    setBusinessPathInUserSession(usess,businessPath);
    if (Windows.getWindows(usess).getAttribute("String_Node_Str") == null) {
      AuthHelper.createAuthHome(ureq);
      String url=getRedirectToURL(usess) + "String_Node_Str" + usess.getSessionInfo().getSession().getId();
      DispatcherAction.redirectTo(response,url);
    }
 else {
      String url=getRedirectToURL(usess);
      DispatcherAction.redirectTo(response,url);
    }
  }
 else {
    setBusinessPathInUserSession(usess,businessPath);
    String invitationAccess=ureq.getParameter(AuthenticatedDispatcher.INVITATION);
    if (invitationAccess != null && LoginModule.isInvitationEnabled()) {
      Locale guestLoc=getLang(ureq);
      int loginStatus=AuthHelper.doInvitationLogin(invitationAccess,ureq,guestLoc);
      if (loginStatus == AuthHelper.LOGIN_OK) {
        Identity invite=usess.getIdentity();
        UserDeletionManager.getInstance().setIdentityAsActiv(invite);
        String url=getRedirectToURL(usess);
        DispatcherAction.redirectTo(response,url);
      }
 else       if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
        DispatcherAction.redirectToServiceNotAvailable(response);
      }
 else {
        DispatcherAction.redirectToDefaultDispatcher(response);
      }
    }
 else {
      String guestAccess=ureq.getParameter(AuthenticatedDispatcher.GUEST);
      if (guestAccess == null || !LoginModule.isGuestLoginLinksEnabled()) {
        DispatcherAction.redirectToDefaultDispatcher(response);
        return;
      }
 else       if (guestAccess.equals(AuthenticatedDispatcher.TRUE)) {
        Locale guestLoc=getLang(ureq);
        int loginStatus=AuthHelper.doAnonymousLogin(ureq,guestLoc);
        if (loginStatus == AuthHelper.LOGIN_OK) {
          String url=getRedirectToURL(usess);
          DispatcherAction.redirectTo(response,url);
        }
 else         if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
          DispatcherAction.redirectToServiceNotAvailable(response);
        }
 else {
          DispatcherAction.redirectToDefaultDispatcher(response);
        }
      }
    }
  }
}