Ticket #22069: see_#22069_fix_issue.patch

File see_#22069_fix_issue.patch, 2.9 KB (added by Schlagi123, 4 years ago)

Patch for the issue

  • src/org/openstreetmap/josm/data/validation/tests/InternetTags.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java b/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java
    a b  
    102102                if (tr("URL contains an invalid protocol: {0}", (String) null).equals(errMsg)) {
    103103                    // Special treatment to allow URLs without protocol. See UrlValidator#isValid
    104104                    String proto = validator instanceof EmailValidator ? "mailto://" : "http://";
    105                     return doValidateTag(p, k, proto+value, validator, code);
     105
     106                    final var valueWithProtocol = proto + value;
     107                    if (validator.isValid(valueWithProtocol)) {
     108                        fix = () -> new ChangePropertyCommand(p, k, valueWithProtocol);
     109                    }
    106110                } else if (tr("URL contains an invalid authority: {0}", (String) null).equals(errMsg)
    107111                        && value.contains("\\") && validator.isValid(value.replaceAll("\\\\", "/"))) {
    108112                    // Special treatment to autofix URLs with backslashes. See UrlValidator#isValid
  • test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
    diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/InternetTagsTest.java
    a b  
    3939     */
    4040    @Test
    4141    void testValidUrls() {
    42         testUrl("url", "www.domain.com", true);                                // No protocol
    4342        testUrl("url", "http://josm.openstreetmap.de", true);                  // Simple HTTP
    4443        testUrl("url", "http://josm.openstreetmap.de/", true);                 // Simple HTTP + slash
    4544        testUrl("website", "https://www.openstreetmap.org", true);             // Simple HTTPS
     
    6564     */
    6665    @Test
    6766    void testInvalidUrls() {
     67        testUrl("url", "www.domain.com", false);                               // No protocol
    6868        testUrl("url", "something://www.domain.com", false);                   // invalid protocol
    6969        testUrl("url", "http://www.domain.invalidtld", false);                 // invalid TLD
    7070    }