I am using Mule and Mule Expression Language to retrieve values form a properties file and change the contents of a connector address based on those values.
Example:
It would read test1
and test2
from the file and store in the variables ${user}
and ${pw}
. It would then use http://${user}:${pw}@testurl.com
as the address for the connector.
Does Mule automatically escape strings when being used in an address? I would assume it doesn't and just uses the exact string provided. Is there a built in method in MEL that can be used to escape strings.
My concern is that the ${user}
could contain a character that is required to be escaped to be interpreted literally, therefore causing an issue with the final url.
My solution if it can't be escaped would be to restrict the valid characters for those 2 parameters and I would like to avoid this.
MEL allows you to use standard Java method invocation so you could use any Java utility to URL encode the string such as URLEncoder - http://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html
For example:
#[java.net.URLEncoder.encode('${user}','UTF-8')]