Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coding forward and backward slashes in tomcat 7?

Tags:

tomcat

tomcat7

I try send request like http://site.com/abc%2Fabc and it doesn't work (send status 400). How I understand tomcat doesn't accept encoded path separators for security reasons, but I don't know how to enable this coding. (I have found only option AllowEncodedSlashes for apache http server). Can you help me?

UPDATE

I fixed this trouble using tiny hack - before render replace all '/' characters on '|' and after reverse this characters on '/'

like image 320
pushistic Avatar asked Mar 15 '12 11:03

pushistic


People also ask

How do you change backward slash to forward slash in Java?

In java, use this: str = str. replace("\\", "/");

What is the difference between forward slashes and backslashes?

Summary: The Backslash and Forward SlashThe backslash (\) is mostly used in computing and isn't a punctuation mark. The forward slash (/) can be used in place of “or” in less formal writing. It's also used to write dates, fractions, abbreviations, and URLs.

Can I use forward slash in Windows path?

You can use forward slashes ( / ) instead of backward slashes ( \ ) on Windows (as is the case with Linux® and UNIX). If you use backward-slashes, the file name on Windows might be treated as a relative-path instead of an absolute-path.


2 Answers

There is a Tomcat option to allow encoded path separators.

Set the CATALINA_OPTS env var to

-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

This will allow encoded slashes.

like image 142
Justin Emery Avatar answered Oct 24 '22 14:10

Justin Emery


We can also add this entry "org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true" in catalina.properties to allow encoded slash in url.


And to allow backslash you have to set different properties. Refer this url for different configuration.

like image 43
user2335780 Avatar answered Oct 24 '22 14:10

user2335780