Link to home
Create AccountLog in
Avatar of srikotesh
srikotesh

asked on

How to resolve path traversal issue in java

Hi Experts,

//Path Traversal Issue
				
String configuration = path +File.separator+"data"+File.separator+temp+File.separator+id+type+"."+frmt;
File newFilePath = new File(configuration);

Open in new window


please suggest how to change the above to resolve path traversal issue.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
That is of course true. But that will only help when you have condensed your tokens, which will require concatenation. You should probably log debug the result of the concatenation such that the reasons for any surprises are instantly visible
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Ah well done - wasn't familiar with that
@CEHJ, thank you.