Skip to content

How to accept Illegal character in query string with ServletHttpHandlerAdapter #25274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
et00448 opened this issue Jun 18, 2020 · 4 comments
Closed
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket)

Comments

@et00448
Copy link

et00448 commented Jun 18, 2020

Hello all,

For legacy reasons in my project based on spring boot 2.2.5 and spring cloud Hoxton.SR4, we should accept non URL encoded character "|" in query string.
We had set the "server.tomcat.relaxed-query-chars=|" in order to let coyotte connector accept this non URL encode character.
But I am facing an issue with ServletHttpHandlerAdapter -> Failed to get request URL: Illegal character in query
How can I deal with illegal caracters in ServletHttpHandlerAdapter like the server.tomcat.relaxed-query-chars do?
Thank's

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 18, 2020
@rstoyanchev rstoyanchev added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Nov 12, 2021
@s50600822
Copy link

s50600822 commented Apr 22, 2023

You can do this


import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;

@Component
public class MyTomcatWebServerCustomizer
        implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {

    @Override
    public void customize(TomcatServletWebServerFactory factory) {
        factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
            @Override
            public void customize(Connector connector) {
                connector.setProperty("relaxedQueryChars", "|");
            }
        });
    }
}

Assuming you are on Tomcat 8, 9 or 10
https://tomcat.apache.org/tomcat-8.5-doc/api/org/apache/catalina/connector/Connector.html
https://tomcat.apache.org/tomcat-9.0-doc/api/org/apache/catalina/connector/Connector.html
https://tomcat.apache.org/tomcat-10.0-doc/api/org/apache/catalina/connector/Connector.html

(I didn't check older version. It may just work the same way.)
tomcat

@snicoll
Copy link
Member

snicoll commented Oct 5, 2023

@et00448 this looks like a question to me which would be better suited to StackOverflow, and sharing an exception snippet that we don't throw ourselves is not really to be sufficient. If you want support, please share a small sample that we can run ourselves to reproduce the behavior that you've described.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Oct 5, 2023
@spring-projects-issues
Copy link
Collaborator

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

@spring-projects-issues spring-projects-issues added the status: feedback-reminder We've sent a reminder that we need additional information before we can continue label Oct 12, 2023
@spring-projects-issues
Copy link
Collaborator

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

@spring-projects-issues spring-projects-issues closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
@spring-projects-issues spring-projects-issues removed status: waiting-for-feedback We need additional information before we can continue status: feedback-reminder We've sent a reminder that we need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket)
Projects
None yet
Development

No branches or pull requests

5 participants