Opened 7 years ago

Last modified 7 years ago

#17684 closed enhancement

Confusing error message for wikipedia tag — at Version 4

Reported by: GerdP Owned by: team
Priority: normal Milestone: 19.05
Component: Core validator Version:
Keywords: template_report Cc: Klumbumbus

Description (last modified by Klumbumbus)

What steps will reproduce the problem?

  1. run validator on the attached file

What is the expected result?

a message like "wikipedia tag should not have URL-encoded values like '%27' "

What happens instead?

The error seems to contain the regExp of the rule:
wikipedia=(?i)^[-a-z]{2,12}:.*%[0-9A-F][0-9A-F] tag should not have URL-encoded values like '%27'

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

Found this tagging in an older OSM file (Relation 1163244).

Build-Date:2019-05-06 07:55:22
Revision:15049
Is-Local-Build:true

Identification: JOSM/1.5 (15049 SVN en) Windows 10 64-Bit
OS Build number: Windows 10 Home 1803 (17134)
Memory Usage: 890 MB / 1753 MB (605 MB allocated, but free)
Java version: 1.8.0_191-b12, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: \Display0 1920x1080
Maximum Screen Size: 1920x1080
VM arguments: [-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:59383, -ea, -Dfile.encoding=UTF-8]
Program arguments: [--debug]
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 (34977)
+ pbf (34908)
+ poly (34991)
+ reverter (34977)
+ undelete (34977)
+ utilsplugin2 (34977)

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

Change History (5)

by GerdP, 7 years ago

Attachment: sample.osm added

comment:1 by GerdP, 7 years ago

The throwError term should probably look like that for wikimedia_commons?

*[wikimedia_commons =~ /%[0-9A-F][0-9A-F]/] {
  throwError: tr("{0} tag should not have URL-encoded values like ''%27''", "{0.key}");
  fixAdd: concat("wikimedia_commons=", trim(replace(URL_decode(tag("wikimedia_commons")), "_", " ")));
  assertMatch: "node wikimedia_commons=File:Foo%27s";
  assertNoMatch: "node wikimedia_commons=File:Foo";
}

*[wikipedia =~ /(?i)^[-a-z]{2,12}:.*%[0-9A-F][0-9A-F]/] {
  throwError: tr("{0} tag should not have URL-encoded values like ''%27''", "{0.tag}");
  fixAdd: concat("wikipedia=", get(regexp_match("(?i)^([-a-z]+:)(.*)$", tag("wikipedia")),1), trim(replace(URL_decode(get(regexp_match("(?i)^([-a-z]+:)(.+)$", tag("wikipedia")),2)), "_", " ")));
  assertMatch: "node wikipedia=en:Foo%27s";
  assertNoMatch: "node wikipedia=en:Foo";
}

comment:2 by GerdP, 7 years ago

Cc: Klumbumbus added

I did not commit this change because I don't fully understand why the current rule produces this result. Maybe there is something else that needs to be fixed.

comment:3 by Klumbumbus, 7 years ago

{0.tag} doesn't work if it referres to a regexp including (?i)

a workaround is to use *[wikipedia][wikipedia =~ /(?i)^[-a-z]{2,12}:.*%[0-9A-F][0-9A-F]/]

or maybe someone finds a proper fix for this in the josm java code.

(see also ticket:17100#comment:26)

comment:4 by Klumbumbus, 7 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.