Modify

Opened 6 years ago

Last modified 4 years ago

#17751 reopened enhancement

error with custom mapcss using regex

Reported by: francians Owned by: team
Priority: normal Milestone:
Component: Core validator Version:
Keywords: template_report Cc:

Description (last modified by Don-vip)

Hello,

I'm building my own validation based on regex and mapcss.
Many thanks for the help

Francesco

What steps will reproduce the problem?

  1. Generate a mapcss file with this rule:
*[amenity=vending_machine][vending!~/(admission_tickets|animal_feed|art|bicycle_tube|books|bottle_return|bread|candles|chemist|chewing_gums|cigarettes|coffee|condoms|drinks|electronics|elongated_coin|excrement_bags|feminine_hygiene|first_aid|fishing_bait|fishing_tackle|flowers|food|fuel|ice_cream|ice_cubes|ink_cartridges|laundry_detergent|lottery|milk|newspapers|parcel_mail_in|parcel_pickup|parking_tickets|public_transport_plans|public_transport_tickets|sex_toys|SIM_cards|stamps|sweets|syringes|telephone_vouchers|toll|toys|umbrellas|water)(?:$|[;](?R))/] {
        throwWarning: tr("unusual value of {0}", "{0.value}");
        group: "MapThisWay";
}
  1. import it in josm
  2. validate

What is the expected result?

to give warning when one value is unknown

What happens instead?

in console I have a lot of:

2019-05-23 21:20:52.475 GRAVE: Skipping to the next rule, because of an error:
2019-05-23 21:20:52.475 GRAVE: org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSException: Error at line 114, column 560: java.util.regex.PatternSyntaxException: Unknown inline modifier near index 518
(admission_tickets|animal_feed|art|bicycle_tube|books|bottle_return|bread|candles|chemist|chewing_gums|cigarettes|coffee|condoms|drinks|electronics|elongated_coin|excrement_bags|feminine_hygiene|first_aid|fishing_bait|fishing_tackle|flowers|food|fuel|ice_cream|ice_cubes|ink_cartridges|laundry_detergent|lottery|milk|newspapers|parcel_mail_in|parcel_pickup|parking_tickets|public_transport_plans|public_transport_tickets|sex_toys|SIM_cards|stamps|sweets|syringes|telephone_vouchers|toll|toys|umbrellas|water)(?:$|[;](?R))

. Causa: java.util.regex.PatternSyntaxException: Unknown inline modifier near index 518

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

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 it) Linux Antergos Linux
Memory Usage: 1337 MB / 3541 MB (622 MB allocated, but free)
Java version: 1.8.0_181-b13, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: :0.0 1920x1080
Maximum Screen Size: 1920x1080
Dataset consistency test: No problems found

Plugins:
+ OpeningHoursEditor (34977)
+ PicLayer (34908)
+ buildings_tools (34982)
+ turnrestrictions (34977)
+ utilsplugin2 (34977)

Tagging presets:
+ ${HOME}/JOSM/miopreset.xml

Validator rules:
+ https://josm.openstreetmap.de/josmfile?page=Rules/SuspiciousSwimming_Pool&zip=1
+ ${HOME}/JOSM/MyRules.validator.mapcss

Last errors/warnings:
- W: No configuration settings found.  Using hardcoded default values for all pools.
- E: org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSException: java.util.regex.PatternSyntaxException: Unknown inline modifier near index 518
- E: Skipping to the next rule, because of an error:
- E: org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSException: Error at line 114, column 560: java.util.regex.PatternSyntaxException: Unknown inline modifier near index 518

Attachments (0)

Change History (11)

comment:1 by Don-vip, 6 years ago

Description: modified (diff)

comment:2 by Don-vip, 6 years ago

Component: CoreCore validator

comment:3 by Don-vip, 6 years ago

Owner: changed from team to francians
Status: newneedinfo

What do you want to write with this? (?:$|[;](?R))

comment:4 by francians, 6 years ago

That's a non capturing group ((?:...)) with semicolon and recursion of pattern ((?R)) or end of line ($).
It works this way:

art -> ok
art; -> ko
art;toll -> ok

It should compile in Java.
Cheers
Francesco

comment:5 by francians, 6 years ago

Owner: changed from francians to team
Status: needinfonew

comment:6 by GerdP, 6 years ago

It doesn't compile with Java 1.8

comment:7 by francians, 6 years ago

I was too lazy to test... it compiles, but it gives runtime error.
If you don't have an alternative way of achieving the same result, I'll think to another approach.
Cheers

comment:8 by GerdP, 6 years ago

Yes, with compile I meant method Pattern.compile(). The java compiler doesn't analyse a regex string.
I think we should stick to the implementation supported in java.

comment:9 by Don-vip, 6 years ago

Resolution: wontfix
Status: newclosed

Java does not support recursion. You must find a Java-compatible way to write this regex.

comment:10 by francians, 5 years ago

Resolution: wontfix
Status: closedreopened
Type: defectenhancement

Hello,

now there is a Java-compatible way to write my expression:

*[amenity=vending_machine][vending][tag("vending") != join_list(";",filter("^(admission_tickets|animal_feed|art|bicycle_tube|books|bottle_return|bread|candles|chemist|chewing_gums|cigarettes|coffee|condoms|drinks|electronics|elongated_coin|excrement_bags|feminine_hygiene|first_aid|fishing_bait|fishing_tackle|flowers|food|fuel|ice_cream|ice_cubes|ink_cartridges|laundry_detergent|lottery|milk|newspapers|parcel_mail_in|parcel_pickup|parking_tickets|public_transport_plans|public_transport_tickets|sex_toys|SIM_cards|stamps|sweets|syringes|telephone_vouchers|toll|toys|umbrellas|water)$",split(";",tag("vending"))))] {
        throwWarning: tr("unusual value of {0}", "{1.key}");
        group: "MapThisWay";
}

See:
https://josm.openstreetmap.de/ticket/18166

Hope to get it merged sooner than later.
Francesco

in reply to:  description comment:11 by skyper, 4 years ago

Below should work.

*[amenity=vending_machine][vending !~ /^((admission_tickets|animal_feed|art|bicycle_tube|books|bottle_return|bread|candles|chemist|chewing_gums|cigarettes|coffee|condoms|drinks|electronics|elongated_coin|excrement_bags|feminine_hygiene|first_aid|fishing_bait|fishing_tackle|flowers|food|fuel|ice_cream|ice_cubes|ink_cartridges|laundry_detergent|lottery|milk|newspapers|parcel_mail_in|parcel_pickup|parking_tickets|public_transport_plans|public_transport_tickets|sex_toys|SIM_cards|stamps|sweets|syringes|telephone_vouchers|toll|toys|umbrellas|water);[ ]?)*(admission_tickets|animal_feed|art|bicycle_tube|books|bottle_return|bread|candles|chemist|chewing_gums|cigarettes|coffee|condoms|drinks|electronics|elongated_coin|excrement_bags|feminine_hygiene|first_aid|fishing_bait|fishing_tackle|flowers|food|fuel|ice_cream|ice_cubes|ink_cartridges|laundry_detergent|lottery|milk|newspapers|parcel_mail_in|parcel_pickup|parking_tickets|public_transport_plans|public_transport_tickets|sex_toys|SIM_cards|stamps|sweets|syringes|telephone_vouchers|toll|toys|umbrellas|water)$/] {
        throwWarning: tr("unusual value of {0}", "{0.value}");
        group: "MapThisWay";
}

Modify Ticket

Change Properties
Set your email in Preferences
Action
as reopened The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user. Next status will be 'new'.
Next status will be 'needinfo'. The owner will be changed from team to francians.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.