You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WQL queries with a multi-line WHERE clause are rejected with WqlSyntaxException #190
Found during the pre-release documentation review (#187).
Problem
A WQL query whose WHERE clause spans several lines is rejected locally with a WqlSyntaxException, although WMI accepts it. Such queries come naturally from Java text blocks or concatenations with \n:
client.wql(""" SELECT Name FROM Win32_Service WHERE State = 'Running' AND StartMode = 'Auto' """).execute(); // WqlSyntaxException, nothing is sent
Checked against the current build (WmiHelper.isValidWql):
Query
Accepted
SELECT Name FROM Win32_Service WHERE State = 'Running' AND StartMode = 'Auto'
yes
SELECT Name FROM Win32_Service + \n + WHERE State = 'Running'
yes
SELECT Name FROM Win32_Service + \n + WHERE State = 'Running' + \n + AND StartMode = 'Auto'
no
Where
WmiHelper.WQL_SIMPLE_SELECT_PATTERN (src/main/java/org/metricshub/winrm/WmiHelper.java) ends with (WHERE\s+.*)?$ and is compiled with Pattern.CASE_INSENSITIVE only. Without Pattern.DOTALL, .* stops at the first line break, so $ cannot match. LightWinRMService.checkWqlArguments uses it for every query, so the legacy WinRMWqlExecutor is affected too.
Expected
Line breaks are accepted anywhere whitespace is, including inside the WHERE clause, probably by adding Pattern.DOTALL, without loosening the grammar otherwise. It stays a single SELECT of * or a property list, FROM one class, and an optional WHERE. ASSOCIATORS OF, REFERENCES OF and event queries stay rejected. Check the legacy WqlQuery parsing for the same issue, and add unit tests for the three cases above.
Activity
Accept multi-line WHERE clauses in WQL queries