Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-15038

HstRequestUtils#getCmsBaseURL produces NPE in case #getPathInfo() is null

    XMLWordPrintable

Details

    • Quasar
    • Team Quasar sprint 284

    Description

      Since a change in 14.7.0, CMS-14514, org.hippoecm.hst.util.HstRequestUtils#getCmsBaseURL produces a NullPointerException in case javax.servlet.http.HttpServletRequest#getPathInfo returns null (which is allowed)

          public static String getCmsBaseURL(final HttpServletRequest cmsHostServletRequest) {
      
             ..snip..
            
             final ResolvedMount resolvedMount = resolvedCmsHost.matchMount(cmsHostServletRequest.getPathInfo());
      

      and ResolvedVirtualHostImpl#matchMount cannot handle null argument:

         public ResolvedMount matchMount(final String requestPath) throws MatchException {
              if(portMount.getRootMount() == null) {
                  log.error("Virtual Host '{}' for portnumber '{}' is not (correctly) mounted: We cannot return a ResolvedMount. Return null", virtualHost.getHostName(), String.valueOf(portMount.getPortNumber()));
                  return null;
              }
      
              // strip leading and trailing slashes
              String path = PathUtils.normalizePath(requestPath);
      
              String matchingIgnoredPrefix = null;
              // check whether the requestPath starts with the cmsPreviewPrefix path: If so, first strip this prefix off and append it later to the resolvedMountPath
      
              if(!StringUtils.isEmpty(virtualHost.getVirtualHosts().getCmsPreviewPrefix())) {
                  if (path.equals(virtualHost.getVirtualHosts().getCmsPreviewPrefix())) {   
                   // path is null!
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jhoffman Jeroen Hoffman
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: