ioBroker.javascript icon indicating copy to clipboard operation
ioBroker.javascript copied to clipboard

$ selector should be able to match against strings or regexes

Open agross opened this issue 5 years ago • 6 comments

$() selector queries are internally transformed into RegExps, with special handling of . and *. Other characters of interest for the RexExp engine are not handled specifically which may lead to unintended results, e.g.:

$('state[id=STATE?]') will find STAT and STATE.

Describe the solution you'd like

Distinguish queries against plain strings and regexes, as suggested by @AlCalzone:

  • $('state[id=*STATE?]') - matched as a string (with handling for wildcards only)
  • $('state[id=~^.*\\.STATE?$]') - matched as a regex (nothing will be escaped, but the user has to escape backslashes)

An interesting case for the query parser will be this:

  • $('state[id=~[aeiou]]') where the query RexExp (/[aeiou]/) contains the characters (]) also interpreted by the query parser.

Additional context

https://github.com/ioBroker/ioBroker.javascript/issues/652#issuecomment-703647308

agross avatar Oct 06 '20 08:10 agross

A little correction: with PR #658, the following is no longer true, because the RegExp input is now sanitized:

$('state[id=STATE?]') will find STAT and STATE.

AlCalzone avatar Oct 06 '20 08:10 AlCalzone

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

stale[bot] avatar Jan 09 '21 23:01 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

stale[bot] avatar Jun 02 '21 17:06 stale[bot]

Unstale

agross avatar Jun 02 '21 17:06 agross

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within the next 7 days. Please check if the issue is still relevant in the most current version of the adapter and tell us. Also check that all relevant details, logs and reproduction steps are included and update them if needed. Thank you for your contributions. Dieses Problem wurde automatisch als veraltet markiert, da es in letzter Zeit keine Aktivitäten gab. Es wird geschlossen, wenn nicht innerhalb der nächsten 7 Tage weitere Aktivitäten stattfinden. Bitte überprüft, ob das Problem auch in der aktuellsten Version des Adapters noch relevant ist, und teilt uns dies mit. Überprüft auch, ob alle relevanten Details, Logs und Reproduktionsschritte enthalten sind bzw. aktualisiert diese. Vielen Dank für Eure Unterstützung.

stale[bot] avatar Sep 03 '21 02:09 stale[bot]

Unstale

agross avatar Sep 03 '21 05:09 agross