Escaping characters in Mule Expression Language - mule

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

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")

Special characters on mule filename

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.

Does mIRC Scripting have an escape character?

I'm trying to write a simple multi-line Alias that says several predefined strings of characters in mIRC. The problem is that the strings can contain:
{
}
|
which are all used in the scripting language to group sections of code/commands. So I was wondering if there was an escape character I could use.
In lack of that, is there a method, or alternative way to be able to "say" multiple lines of these strings, so that this:
alias test1 {
/msg # samplestring}contains_chars|
/msg # _that|break_continuity}{
}
Outputs this on typing /test1 on a channel:
<MyName> samplestring}contains_chars|
<MyName> _that|break_continuity}{
It doesn't have to use the /msg command specifically, either, as long as the output is the same.
So basically:
Is there an escape character of sorts I can use to differentiate code from a string in mIRC scripting?
Is there a way to tell a script to evaluate all characters in a string as a literal? Think " " quotes in languages like Java.
Is the above even possible using only mIRC scripting?
"In lack of that, is there a method, or alternative way to be able to "say" multiple lines of these strings, so that this:..."
I think you have to have to use msg # every time when you want to message a channel. Alterativelty you can use the /say command to message the active window.
Regarding the other 3 questions:
Yes, for example you can use $chr(123) instead of a {, $chr(125) instead of a } and $chr(124) instead of a | (pipe). For a full list of numbers you can go to http://www.atwebresults.com/ascii-codes.php?type=2. The code for a dot is 46 so $chr(46) will represent a dot.
I don't think there is any 'simple' way to do this. To print identifiers as plain text you have to add a ! after the $. For example '$!time' will return the plain text '$time' as $time will return the actual value of $time.
Yes.

Openfire: Offline UTF-8 encoded messages are saved wrong

We use Openfire 3.9.3. Its MySql database uses utf8_persian_ci collation and in openfire.xml we have:
...<defaultProvider>
<driver>com.mysql.jdbc.Driver</driver>
<serverURL>jdbc:mysql://localhost:3306/openfire?useUnicode=true&amp;characterEncoding=UTF-8</serverURL>
<mysql>
<useUnicode>true</useUnicode>
</mysql> ....
The problem is that offline messages which contain Persian characters (UTF-8 encoded) are saved as strings of question marks. For example سلام (means hello in Persian) is stored and showed like ????.
MySQL does not have proper Unicode support, which makes supporting data in non-Western languages difficult. However, the MySQL JDBC driver has a workaround which can be enabled by adding
?useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8
to the URL of the JDBC driver. You can edit the conf/openfire.xml file to add this value.
Note: If the mechanism you use to configure a JDBC URL is XML-based, you will need to use the XML character literal & to separate configuration parameters, as the ampersand is a reserved character for XML.
Also be sure that your DB and tables have utf8 encoding.

Selenium: Part of text present

Is there a way to verify only part of text present?
If there is a text "Warning: A15P09 has not been activated." I need to verify the text is present. However, 'A15P09' is not always the same, so I cannot do something like
Selenium.IsTextPresent("Warning: A15P09 has not been activated.");
I might do something like:
Selenium.IsTextPresent("has not been activated.");
But is there another way to verify this in Selenium. Please let me know if there is.
Thanks!
You could use getText and then do any normal regex that your language supplies for examining that result.
Edit: And for some languages you can do isTextPresent on a pattern modified string. The documentation states:
Various Pattern syntaxes are available
for matching string values:
glob:pattern: Match a string against a
"glob" (aka "wildmat") pattern. "Glob"
is a kind of limited
regular-expression syntax typically
used in command-line shells. In a glob
pattern, "*" represents any sequence
of characters, and "?" represents any
single character. Glob patterns match
against the entire string.
regexp:regexp: Match a string using a
regular-expression. The full power of
JavaScript regular-expressions is
available.
exact:string: Match a
string exactly, verbatim, without any
of that fancy wildcard stuff.
If no
pattern prefix is specified, Selenium
assumes that it's a "glob" pattern.