Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-4703

Infinite Redirect Loop if invalid Accept header

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.2, 4.1.0
    • 5.0.0, 4.0.3, 4.1.1
    • General
    • None

    Description

      Original PrimeFaces Issue: https://github.com/primefaces/primefaces/issues/13104

      IF you hit a MyFaces app using PrimeFaces and the Content-Type is invalid it gets in an infinite redirect loop if you have an `error-page` mapped.

      Dec 21, 2024 10:09:19 AM org.primefaces.application.exceptionhandler.PrimeExceptionHandler logException
      SEVERE: ContentTypeList does not contain a supported content type: text/plain
      java.lang.IllegalArgumentException: ContentTypeList does not contain a supported content type: text/plain
              at org.apache.myfaces.renderkit.html.HtmlRenderKitImpl.createResponseWriter(HtmlRenderKitImpl.java:311)
              at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.createResponseWriter(FaceletViewDeclarationLanguage.java:2116)
              at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1751)
              at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:316)
              at jakarta.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:74)
              at jakarta.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:74)
              at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:122)
              at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
              at jakarta.faces.lifecycle.LifecycleWrapper.render(LifecycleWrapper.java:43)
              at jakarta.faces.webapp.FacesServlet.service(FacesServlet.java:225)
      

      1. Simply run the Showcase using MyFaces 4.0
      2. Execute `curl` or `PowerShell` to hit the site with an invalid Content-Type.

      Unable to find source-code formatter for language: powershell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      $response = Invoke-WebRequest -Uri "http://localhost:8080/showcase/ui/ajax/process.xhtml" -Method GET -Headers @{ Accept = "text/plain" } -AllowInsecureRedirect
      

      3. Because it gets the error it tries to redirect to `/showcase/error.xhtml` using `externalContext.redirect(url);`. This however just generates the same error in MyFaces in an infinite loop.

      Attachments

        Activity

          People

            melloware Melloware
            melloware Melloware
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: