Special characters on mule filename - mule

I am using an email subject in my flow as the file name of the output file. however, sometimes there are special characters in the subject line that triggers an error when writing the files to my outbound file endpoint.is there a way to convert it on the flow? or can I force it to write on the endpoint?
any suggestions?

Use a MEL expression to normalize the subject into an acceptable file name. In the expression, use one of the helper methods available in org.mule.util.StringUtil to perform the cleanup.

Related

Ignoring wildcard function of FollowHyperlink within a text string in VBA

I am trying to open a file path in Explorer using the .FollowHyperlink method and get errors on the strings with the "#" character. How do I format the string to make .FollowHyperlink ignore the wildcard functionality? For instance how would I format the following file path:
G:\Building\#500 Main St.\Loans\
You can use Shell for this:
Shell "C:\WINDOWS\explorer.exe ""G:\Building\#500 Main St.\Loans\""", vbNormalFocus
We can tell by looking at the documentation that the first argument is expected to be an Address which must follow the rules of a valid URI as defined in the RFC.
The hash # is a reserved symbol in the URI RFC.
You would have to URL Encode any string you pass in to it to avoid reserved symbols. There is no built-in method to URL encode strings in Access, but there is in Excel.
You can see a full discussion of URL Encode in VBA here:
How can I URL encode a string in Excel VBA?
Here is an example of your URL encoded local path:
FollowHyperlink("G%3A%5CBuilding%5C%23500%20Main%20St.%5CLoans%5C")

Multi-line text in a .env file

In vue, is there a way to have a value span multiple lines in an .env file. Ex:
Instead of:
someValue=[{"someValue":"Here is a really really long piece which should be split into multiple lines"}]
I want to do something like:
someValue=`[{"someValue":"Here is a really
really long piece which
should be split into multiple lines"}]`
Doing the latter gives me a JSON parsing error if I try to do JSON.parse(someValue) in my code
I don't know if this will work, but I can't format a comment appropriately enough to get the point across so see if this will work:
someValue=[{"someValue":"Here is a really\
really long piece which\
should be split into multiple lines"}]
Where "\" should escape the newline similar to how you can write long bash commands while escaping the newline. I'm not certain the .env interpreter will support it though.
EDIT
Looks like this won't work. This syntax was actually proposed, but I don't think it was incorporated. See motdotla/dotenv#333 (which is what Vue uses to parse .env).
Like #zero298 said, this isn't possible. Likely you could delimit the entry with a character that wouldn't show up normally in the text (^ is a good candidate), then parse it within the application using string.replace('^', '\n');

Escaping characters in Mule Expression Language

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')]

Reading blocks of text from a CSV file - vb.net

I need to parse a CSV file with blocks of text being processed in different ways according to certain rules, e.g.
userone,columnone,columntwo
userthirteen,columnone,columntwo
usertwenty,columnone,columntwo
customerone,columnone<br>
customertwo,columntwo<br>
singlevalueone
singlevaluetwo
singlevalueone_otherruleapplies
singlevaluethree_otherruleapplies
Each block of text will be grouped so the first three rows will be parsed using certain rules and so on. Notice that the last two groups have only one single column but each group must be handled in a different way.
I have the chance to propose the customer the format of the file so I'm thinking to propose the following.
[group 1]
userone,columnone,columntwo
userthirteen,columnone,columntwo
usertwenty,columnone,columntwo
[group N]
rowN
A kind of sections like the INI files from some years ago. However I'd like to hear your comments because I think there must be a better way to handle this.
I proposed to use XML but the customer prefers the text files.
Any suggestions are welcome.
m0dest0.
Ps. using VB.net and VS 2008
You can use regular expression groups set to either an enum line mode if each line has the same format, or to an enum multi-line if the format is not constrained to a single line. For each line in multiline you can include \n in your pattern to cross multiple lines to find you pattern. If its on a single line you don't need to include \n also know as Carriage return line feed in your regex matching pattern.
vb.net as well as many other modern programming language has extensive support for grouping operations. You can use index groups, or named groups.
Each name such as header1 or whatever you want to name it would be in this format: <myname>
See this link for more info: How do I access named capturing groups in a .NET Regex?.
Good luck.

MSBuild string that has this format $(SomeText)

in my MSBuild every text that has this pattern $(SomeText) is considered as property reference. I have an MSBuild Custom Task that writes content to some text file and the text that needs to be written is $(SomeText) thus MSBuild does not let this pass through because it is considered as properry reference.
Any workaround.
Many thanks,
Idriss
MSBuild uses same escaping as in URL. Use %24 instead of $
Here and here is a full list of ASCII character codes