Author Topic: Tasker Event Plugin: How to search literal asterisks and brackets?  (Read 2020 times)

derandiunddasbo

  • Newbie
  • *
  • Posts: 2
Tasker Event Plugin: How to search literal asterisks and brackets?
« 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?

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Tasker Event Plugin: How to search literal asterisks and brackets?
« Reply #1 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 ?");
}
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/

derandiunddasbo

  • Newbie
  • *
  • Posts: 2
Re: Tasker Event Plugin: How to search literal asterisks and brackets?
« Reply #2 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.  :)

Kostya Vasilyev

  • Hero Member
  • *****
  • Posts: 12740
Re: Tasker Event Plugin: How to search literal asterisks and brackets?
« Reply #3 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...
Creating debug logs for diagnostics: https://www.aqua-mail.com/troubleshooting/

The official FAQ: https://www.aqua-mail.com/faq/

Лог-файлы для диагностики: https://www.aqua-mail.com/ru/troubleshooting/

Вопросы и ответы: https://www.aqua-mail.com/ru/faq/