Changeset 18407 in josm for trunk/src


Ignore:
Timestamp:
2022-03-22T17:10:25+01:00 (3 years ago)
Author:
stoecker
Message:

fix #21756 - strip typical privacy relevant parameters from URL output

File:
1 edited

Legend:

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

    r18332 r18407  
    126126
    127127    /**
     128     * Removed privacy related parts form output URL
     129     * @param url Unmodified URL
     130     * @return Stripped URL (privacy related issues removed)
     131     */
     132    private String stripUrl(URL url) {
     133        return url.toString().replaceAll("(token|key|connectId)=[^&]+","$1=...stripped...");
     134    }
     135
     136    /**
    128137     * Opens the HTTP connection.
    129138     * @param progressMonitor progress monitor
     
    149158                final boolean hasReason = !Utils.isEmpty(reasonForRequest);
    150159                logRequest("{0} {1}{2} -> {3} {4} ({5}{6})",
    151                         getRequestMethod(), getURL(), hasReason ? (" (" + reasonForRequest + ')') : "",
     160                        getRequestMethod(), stripUrl(getURL()), hasReason ? (" (" + reasonForRequest + ')') : "",
    152161                        cr.getResponseVersion(), cr.getResponseCode(),
    153162                        stopwatch,
     
    167176                }
    168177            } catch (IOException | RuntimeException e) {
    169                 logRequest("{0} {1} -> !!! ({2})", requestMethod, url, stopwatch);
     178                logRequest("{0} {1} -> !!! ({2})", requestMethod, stripUrl(url), stopwatch);
    170179                Logging.warn(e);
    171180                //noinspection ThrowableResultOfMethodCallIgnored
Note: See TracChangeset for help on using the changeset viewer.