Changeset 7786 in josm for trunk


Ignore:
Timestamp:
2014-12-10T23:36:01+01:00 (5 years ago)
Author:
Don-vip
Message:

see #10816 - fix text parsing regressions

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r7783 r7786  
    204204        // Format
    205205        // tag1\tval1\ntag2\tval2\n
    206         tags = readTagsByRegexp(buf, "[\\r\\n]+", "([a-zA-Z0-9:_]+)\\t(.*?)", false);
     206        tags = readTagsByRegexp(buf, "[\\r\\n]+", ".*([a-zA-Z0-9:_]+).*\\t(.*?)", false);
    207207                // try "tag\tvalue\n" format
    208208        if (tags!=null) return tags;
     
    213213        // a = "b=c" is OK
    214214        // a = b=c  - this method of parsing fails intentionally
    215         tags = readTagsByRegexp(buf, "[\\n\\t\\r]+", "([a-zA-Z0-9:_]+)=(.*?)", true);
     215        tags = readTagsByRegexp(buf, "[\\n\\t\\r]+", "(.*?)=(.*?)", true);
    216216                // try format  t1=v1\n t2=v2\n ...
    217217        if (tags!=null) return tags;
  • trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

    r7081 r7786  
    3939    @Test
    4040    public void testTNformat() {
    41         String txt = "   a  \t  1   \n\n\n  b=2 \t the value with \"quotes\"";
     41        String txt = "   a  \t  1   \n\n\n  b\t2 \n c \t the value with \"quotes\"";
    4242        Map<String, String> correctTags = new HashMap<String, String>() { {
    43             put("a", "1"); put("b=2", "the value with \"quotes\"");
     43            put("a", "1"); put("b", "2"); put("c", "the value with \"quotes\"");
    4444        }};
    4545        Map<String, String> tags = TextTagParser.readTagsFromText(txt);
Note: See TracChangeset for help on using the changeset viewer.