Changeset 18869 in josm


Ignore:
Timestamp:
2023-10-13T13:50:04+02:00 (8 months ago)
Author:
taylor.smock
Message:

Fix #23235: Allow unicode characters in URL paths

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java

    r18801 r18869  
    132132     * Protocol scheme (e.g. http, ftp, https).
    133133     */
    134     private static final String SCHEME_REGEX = "^\\p{Alpha}[\\p{Alnum}\\+\\-\\.]*";
     134    private static final String SCHEME_REGEX = "^\\p{Alpha}[\\p{Alnum}+\\-.]*";
    135135    private static final Pattern SCHEME_PATTERN = Pattern.compile(SCHEME_REGEX);
    136136
     
    138138    // TODO does not allow for optional userinfo.
    139139    // Validation of character set is done by isValidAuthority
    140     private static final String AUTHORITY_CHARS_REGEX = "\\p{Alnum}\\-\\."; // allows for IPV4 but not IPV6
     140    private static final String AUTHORITY_CHARS_REGEX = "\\p{Alnum}-\\."; // allows for IPV4 but not IPV6
    141141    private static final String IPV6_REGEX = "[0-9a-fA-F:]+"; // do this as separate match because : could cause ambiguity with port prefix
    142142
     
    151151            USERINFO_CHARS_REGEX + "*@"; // password may be absent
    152152    private static final String AUTHORITY_REGEX =
    153             "(?:\\[("+IPV6_REGEX+")\\]|(?:(?:"+USERINFO_FIELD_REGEX+")?([" + AUTHORITY_CHARS_REGEX + "]*)))(:\\d*)?(.*)?";
     153            "(?:\\[("+IPV6_REGEX+")]|(?:(?:"+USERINFO_FIELD_REGEX+")?([" + AUTHORITY_CHARS_REGEX + "]*)))(:\\d*)?(.*)?";
    154154    //             1                          e.g. user:pass@          2                                   3       4
    155155    private static final Pattern AUTHORITY_PATTERN = Pattern.compile(AUTHORITY_REGEX);
     
    164164    private static final int PARSE_AUTHORITY_EXTRA = 4;
    165165
    166     private static final String PATH_REGEX = "^(/[-\\w:@&?=+,.!/~*'%$_;\\(\\)]*)?$";
    167     private static final Pattern PATH_PATTERN = Pattern.compile(PATH_REGEX);
     166    private static final String PATH_REGEX = "^(/[-\\w:@&?=+,.!/~*'%$_;()]*)?$";
     167    private static final Pattern PATH_PATTERN = Pattern.compile(PATH_REGEX, Pattern.UNICODE_CHARACTER_CLASS);
    168168
    169169    private static final String QUERY_REGEX = "^(.*)$";
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/UrlValidatorTest.java

    r18690 r18869  
    565565            new ResultPair("/test1/file", true),
    566566            new ResultPair("/..//file", false),
    567             new ResultPair("/test1//file", false)
     567            new ResultPair("/test1//file", false),
     568            new ResultPair("/projekte-und-themen/eulen-falken-und-deren-nistkästen/trafotürme", true)
    568569    };
    569570
Note: See TracChangeset for help on using the changeset viewer.