Modify

Opened 5 months ago

Closed 5 months ago

#17746 closed enhancement (fixed)

[Patch] Detect invalid MapCSS search expressions

Reported by: GerdP Owned by: GerdP
Priority: normal Milestone: 19.05
Component: Core Version:
Keywords: template_report Cc: Don-vip, Klumbumbus, qeef

Description

What steps will reproduce the problem?

  1. Create dataset with a highway and a building.
  2. Open search dialog in expert mode and type search expression
    *[building] aaa *[highway]
    
  3. Note that the input field is marked red. Change aaa to e.g. # or + or - or (Euro symbol)

What is the expected result?

The input field should always be red and pressing "Start search" should show a popup with
"Search expression is not valid"

What happens instead?

The search field is not marked red, the search finds the building when - or # or is used,
but not with +.

Please provide any additional information below. Attach a screenshot if possible.

Found this because it also doens't complain when the operators ⊆,⊈,⊇,⊉ are used which were introduced for #10391 with r15102. See also ticket:10391#comment:70

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2019-04-28 04:36:41 +0200 (Sun, 28 Apr 2019)
Build-Date:2019-04-28 02:37:58
Revision:15031
Relative:URL: ^/trunk

Identification: JOSM/1.5 (15031 en) Windows 10 64-Bit
OS Build number: Windows 10 Home 1803 (17134)
Memory Usage: 602 MB / 1820 MB (304 MB allocated, but free)
Java version: 1.8.0_201-b09, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: \Display0 1920x1080
Maximum Screen Size: 1920x1080
VM arguments: [-XX:StartFlightRecording=name=MyRecording2,settings=d:\dbg\gerd.jfc, -XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=e:\ld\perf_20190523_074719.jfr]
Dataset consistency test: No problems found

Plugins:
+ OpeningHoursEditor (34977)
+ apache-commons (34908)
+ buildings_tools (34982)
+ continuosDownload (82)
+ ejml (34908)
+ geotools (34908)
+ jaxb (34908)
+ jts (34908)
+ o5m (34908)
+ opendata (34997)
+ pbf (34908)
+ poly (34991)
+ reverter (34999)
+ undelete (34977)
+ utilsplugin2 (34977)

Validator rules:
+ c:\josm\core\data\validator\geometry.mapcss

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.

Attachments (2)

17746.patch (1.6 KB) - added by GerdP 5 months ago.
use trick to trigger parser exception
17746-v2.patch (1.4 KB) - added by GerdP 5 months ago.

Download all attachments as: .zip

Change History (10)

comment:1 Changed 5 months ago by GerdP

I think the special case with + is caused by the (undocumented) "Sibling" selector. This was introdued with r6927 but seems to be unused by core validator since r10084. No idea if this operator is still in use? Anyway, it is not the root cause for this ticket.

Changed 5 months ago by GerdP

Attachment: 17746.patch added

use trick to trigger parser exception

comment:2 Changed 5 months ago by GerdP

Cc: Don-vip Klumbumbus added

Not sure where to fix this. Maybe in method SearchCompiler.compileMapCSS()?
This method calls MapCSSParser.selectors() and that method returns the selector "*[building]". I think we should detect
that there are more tokens in the input stream not yet processed by the parser and when this is the case the search expression is not valid.
Attached patch implements a trick to force a ParseException by adding a declarition to the search string and later checking if this was parsed correctly.

comment:3 Changed 5 months ago by Don-vip

I feel this trick should not be needed and the parser should be able to return the list of unprocessed parts, that you can then check for emptiness.

Changed 5 months ago by GerdP

Attachment: 17746-v2.patch added

comment:4 Changed 5 months ago by GerdP

Please review. I think I found a good solution with 17746-v2.patch.

comment:5 Changed 5 months ago by GerdP

Milestone: 19.05
Owner: changed from team to GerdP
Status: newassigned
Summary: Detect invalid MapCSS search expressions[Patch] Detect invalid MapCSS search expressions

comment:6 Changed 5 months ago by qeef

Cc: qeef added

comment:7 Changed 5 months ago by Don-vip

much better :)

comment:8 Changed 5 months ago by GerdP

Resolution: fixed
Status: assignedclosed

In 15113/josm:

fix #17746: Detect invalid MapCSS search expressions

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain GerdP.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.