AquaMail Forum

English - Android => How do I... => Topic started by: derandiunddasbo on September 09, 2018, 05:15:29 pm

Title: Tasker Event Plugin: How to search literal asterisks and brackets?
Post by: derandiunddasbo on September 09, 2018, 05:15:29 pm
Well, the subject says it all: I want to detect mails with subjects beginning with "[***  ] Blah Blah ..." with three to five asterisks between the brackets. But everything I tried until now didn't work.

As I didn't find any documentation about the AquaMail Tasker plugin, I don't know, if I can use literal brackets or asterisks in filters or if they have to be escaped somehow. And if so, how?

Can anybody enlighten me, how to deal with special chars in the AquaMail event plugin config?
Title: Re: Tasker Event Plugin: How to search literal asterisks and brackets?
Post by: Kostya Vasilyev on September 11, 2018, 10:43:33 pm
Please try

*blah*

as your query string.

You should also be able to do

[***]*

"*" in first and/or last positions are converted to SQL "%" which are then used in LIKE operator.

final int len = value.length();
if (value.charAt(0) == '*') {
   value = "%" + value.substring(1);
   like = true;
}
if (len > 1 && value.charAt(len - 1) == '*') {
   value = value.substring(0, len - 1) + "%";
   like = true;
}

if (like) {
   query.append(" AND IFNULL(").append(columnName).append(", \"\") LIKE ?");
}
Title: Re: Tasker Event Plugin: How to search literal asterisks and brackets?
Post by: derandiunddasbo on September 12, 2018, 10:03:01 am
Ah ok, SQL syntax. That's the one thing I didn't try before.

Thanks for the explanation. :)

This behavior might be worth a FAQ entry, as it is not very obvious, how search strings are parsed by the plugin. Especially the different handling of asterisks, depending on the position in the search pattern.

While we are at it: Did you check, how the parser handles literal percent signs? If they are not escaped before passing them to the SQL search, this may also lead to unexpected results. I admit that this is not a very common use case, but may spare you one or two support cases in the future.  :)
Title: Re: Tasker Event Plugin: How to search literal asterisks and brackets?
Post by: Kostya Vasilyev on September 14, 2018, 07:33:02 pm
Quote
While we are at it: Did you check, how the parser handles literal percent signs? If they are not escaped before passing them to the SQL search, this may also lead to unexpected results. I admit that this is not a very common use case, but may spare you one or two support cases in the future.  :)

No I didn't check but this is SQLite docs:

https://www.sqlite.org/lang_expr.html#like

A percent symbol ("%") in the LIKE pattern matches any sequence of zero or more characters in the string. An underscore ("_") in the LIKE pattern matches any single character in the string. Any other character matches itself...