Ignore:
Timestamp:
2018-03-23T22:22:05+01:00 (6 years ago)
Author:
stoecker
Message:

some imagery sanity checks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/SyncEditorLayerIndex.groovy

    r13549 r13551  
    2525import org.openstreetmap.josm.data.imagery.ImageryInfo
    2626import org.openstreetmap.josm.data.imagery.Shape
    27 import org.openstreetmap.josm.data.projection.Projections;
     27import org.openstreetmap.josm.data.projection.Projections
     28import org.openstreetmap.josm.data.validation.routines.DomainValidator
    2829import org.openstreetmap.josm.io.imagery.ImageryReader
    2930
     
    552553                    myprintln "- Missing JOSM license URL (${et}): ${getDescription(j)}"
    553554                } else if (et) {
    554                     myprintln "* License URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
     555                    def ethttps = et.replace("http:","https:")
     556                    if(jt.equals(ethttps) || jt.equals(et+"/") || jt.equals(ethttps+"/")) {
     557                        myprintln "+ License URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
     558                    } else {
     559                        myprintln "* License URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
     560                    }
    555561                } else if (!options.nomissingeli) {
    556562                    myprintln "+ Missing ELI license URL ('${jt}'): ${getDescription(j)}"
     
    565571                } else if (et) {
    566572                    def ethttps = et.replace("http:","https:")
    567                     if(jt.equals(ethttps)) {
     573                    if(jt.equals(ethttps) || jt.equals(et+"/") || jt.equals(ethttps+"/")) {
    568574                        myprintln "+ Attribution URL differs ('${et}' != '${jt}'): ${getDescription(j)}"
    569575                    } else {
     
    715721        def josmIds = new HashMap<String, ImageryInfo>()
    716722        def all = Projections.getAllProjectionCodes()
     723        DomainValidator dv = DomainValidator.getInstance();
    717724        for (def url : josmUrls.keySet()) {
    718725            def j = josmUrls.get(url)
     
    750757                }
    751758            }
    752             if(!(url =~ /^https?:\/\//) && !"scanex".equals(getType(j))) {
    753                 myprintln "* Strange URL: ${getDescription(j)}"
    754             }
     759            def urls = new LinkedList<String>()
     760            if(!"scanex".equals(getType(j))) {
     761              urls += url
     762            }
     763            def jt = getPermissionReferenceUrl(j)
     764            if(jt)
     765              urls += jt
     766            jt = getTermsOfUseUrl(j)
     767            if(jt)
     768              urls += jt
     769            jt = getAttributionUrl(j)
     770            if(jt)
     771              urls += jt
     772            for(def u : urls) {
     773                def m = u =~ /^https?:\/\/([^\/]+?)(:\d+)?\//
     774                if(!m)
     775                    myprintln "* Strange URL '${u}': ${getDescription(j)}"
     776                else {
     777                    def domain = m[0][1].replaceAll("\\{switch:.*\\}","x")
     778                    if (!(domain =~ /^\d+\.\d+\.\d+\.\d+$/) && !dv.isValid(domain))
     779                        myprintln "* Strange Domain '${domain}': ${getDescription(j)}"
     780                }
     781            }
     782
    755783            if(josmMirrors.containsKey(url)) {
    756784                continue
Note: See TracChangeset for help on using the changeset viewer.