craftercms / craftercms

Parent project for Crafter CMS. Issue tracking across all repositories and global builds.
GNU General Public License v3.0
282 stars 98 forks source link

Adding a non-existent or non-defined macros into `Destination Path Pattern` and using quick create, will launch an error form that can't be closed #6705

Open Euquimides opened 3 weeks ago

Euquimides commented 3 weeks ago

Duplicates

Latest version

Describe the issue

Adding a non-existent or non-defined macros into Destination Path Pattern and using quick create, will launch an error form that can't be closed.

Expected from the fix: we need some way to validate macros in the Content-Type creation form, to avoid this kind of issues.

Steps to reproduce

Steps:

  1. Create a new project, it can be based in Editorial.
  2. Go to Project Tools > Content Types > Article
  3. On "Destination Path Pattern" add a non-existen or non-defined macro, such as {blah}.
  4. Save the Content Type.
  5. Refresh the Browser window.
  6. Go to Quick Create and try to create a new Article, the form will show an error, and it can't be closed.

Relevant log output

HTTP Status 400 – Bad Request

Type Exception Report

Message Invalid character found in the request target [/studio/form?site=a1&form=/page/article&path=/site/website/articles/{blah}&isInclude=undefined&iceComponent=true&editorId=a790baff-a074-eac8-9512-d2634498fb81 ]. The valid characters are defined in RFC 7230 and RFC 3986

Description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

Exception

java.lang.IllegalArgumentException: Invalid character found in the request target [/studio/form?site=a1&form=/page/article&path=/site/website/articles/{blah}&isInclude=undefined&iceComponent=true&editorId=a790baff-a074-eac8-9512-d2634498fb81 ]. The valid characters are defined in RFC 7230 and RFC 3986
    org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:482)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:263)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1794)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
    java.base/java.lang.Thread.run(Thread.java:840)

Note The full stack trace of the root cause is available in the server logs.

Screenshots and/or videos

https://github.com/craftercms/craftercms/assets/90878288/9c98ffed-e862-40d0-befd-39abe9ee88cf

Screenshot from 2024-04-23 12-55-09

rart commented 3 weeks ago

@jvega190 the error is caused by unrecognised macros ending up on the url e.g. /site/website/{mm}/{hello} => /site/website/04/{hello}. Let's make the macro processor remove unrecognised macros so /site/website/{mm}/{hello} => /site/website/04