Changeset 9857 in josm for trunk


Ignore:
Timestamp:
2016-02-23T19:36:31+01:00 (9 years ago)
Author:
simon04
Message:

fix #12549 - MapCSS: permit using character classes in regexp: \p{...}

Location:
trunk
Files:
2 edited

Legend:

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

    r9336 r9857  
    162162|   < STRING: "\"" ( [" ","!","#"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\\"" | "\\\\" )*  "\"" >
    163163|   < #PREDEFINED: "\\" ["d","D","s","S","w","W","b","B","A","G","Z","z"] >
    164 |   < #REGEX_CHAR_WITHOUT_STAR: [" "-")","+"-".","0"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\/" | "\\\\" | "\\[" | "\\]" | "\\+" | "\\." | "\\'" | "\\\"" |  "\\(" | "\\)" | "\\{" | "\\}" | "\\?" | "\\*" | "\\^" | "\\$" | "\\|" |<PREDEFINED> >
     164|   < #REGEX_CHAR_WITHOUT_STAR: [" "-")","+"-".","0"-"[","]"-"~","\u0080"-"\uFFFF"] | "\\/" | "\\\\" | "\\[" | "\\]" | "\\+" | "\\." | "\\'" | "\\\"" |  "\\(" | "\\)" | "\\{" | "\\}" | "\\?" | "\\*" | "\\^" | "\\$" | "\\|" | "\\p" |<PREDEFINED> >
    165165|   < REGEX: "/" <REGEX_CHAR_WITHOUT_STAR> ( <REGEX_CHAR_WITHOUT_STAR> | "*" )*  "/" >
    166166|   < LBRACE: "{" >
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.groovy

    r8784 r9857  
    433433        assert mc.getCascade(Environment.DEFAULT_LAYER).get("max_split", -777f, Float.class) == 56
    434434    }
     435
     436    @Test
     437    public void testTicket12549() throws Exception {
     438        def condition = getParser("[name =~ /^(?i)(?u)fóo\$/]").condition(Condition.Context.PRIMITIVE)
     439        assert condition.applies(new Environment(OsmUtils.createPrimitive("way name=fóo")))
     440        assert condition.applies(new Environment(OsmUtils.createPrimitive("way name=fÓo")))
     441        condition = getParser("[name =~ /^(\\p{Lower})+\$/]").condition(Condition.Context.PRIMITIVE)
     442        assert !condition.applies(new Environment(OsmUtils.createPrimitive("way name=fóo")))
     443        condition = getParser("[name =~ /^(?U)(\\p{Lower})+\$/]").condition(Condition.Context.PRIMITIVE)
     444        assert condition.applies(new Environment(OsmUtils.createPrimitive("way name=fóo")))
     445        assert !condition.applies(new Environment(OsmUtils.createPrimitive("way name=fÓo")))
     446    }
    435447}
Note: See TracChangeset for help on using the changeset viewer.