Changeset 9247 in josm


Ignore:
Timestamp:
2016-01-01T22:34:11+01:00 (6 years ago)
Author:
simon04
Message:

fix #12267 - MapCSS conditions does not handle unquoted 0 value

Such as in [frequency=0].

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParser.jj

    r9239 r9247  
    157157{
    158158    < IDENT: ["a"-"z","A"-"Z","_"] ( ["a"-"z","A"-"Z","_","-","0"-"9"] )* >
    159 |   < UINT: ["1"-"9"] ( ["0"-"9"] )* >
     159|   < UINT: ( ["0"-"9"] )+ >
    160160|   < STRING: "\"" ( [" ","!","#"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\\"" | "\\\\" )*  "\"" >
    161161|   < #PREDEFINED: "\\" ["d","D","s","S","w","W","b","B","A","G","Z","z"] >
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/KeyValueConditionTest.groovy

    r9214 r9247  
    101101        assert selNeg.matches(new Environment(OsmUtils.createPrimitive("way foo=bar src=1,2")))
    102102    }
     103
     104    @Test
     105    public void testValueFive() throws Exception {
     106        // ticket #5985
     107        def sel = new MapCSSParser(new StringReader("*[width=5]")).selector()
     108        assert sel.matches(new Environment(OsmUtils.createPrimitive("way highway=track width=5")))
     109        assert !sel.matches(new Environment(OsmUtils.createPrimitive("way highway=track width=2")))
     110    }
     111
     112    @Test
     113    public void testValueZero() throws Exception {
     114        // ticket #12267
     115        def sel = new MapCSSParser(new StringReader("*[frequency=0]")).selector()
     116        assert sel.matches(new Environment(OsmUtils.createPrimitive("way railway=rail frequency=0")))
     117        assert !sel.matches(new Environment(OsmUtils.createPrimitive("way railway=rail frequency=50")))
     118    }
    103119}
Note: See TracChangeset for help on using the changeset viewer.