Changeset 15261 in josm for trunk/src


Ignore:
Timestamp:
2019-07-23T14:39:03+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17935 - fix bad HTTP request construction when contacting OSM wiki

File:
1 edited

Legend:

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

    r14641 r15261  
    4646    public Optional<String> findExistingPage(List<String> pages)
    4747            throws IOException, ParserConfigurationException, SAXException, XPathExpressionException {
     48        List<String> distinctPages = pages.stream().distinct().collect(Collectors.toList());
    4849        // find a page that actually exists in the wiki
    4950        // API documentation: https://wiki.openstreetmap.org/w/api.php?action=help&modules=query
    50         final URL url = new URL(baseUrl + "/w/api.php?action=query&format=xml&titles=" + pages.stream()
     51        final URL url = new URL(baseUrl + "/w/api.php?action=query&format=xml&titles=" + distinctPages.stream()
    5152                .map(Utils::encodeUrl)
    52                 .collect(Collectors.joining("|"))
     53                .collect(Collectors.joining(Utils.encodeUrl("|")))
    5354        );
    5455        final HttpClient.Response conn = HttpClient.create(url).connect();
     
    5960        conn.disconnect();
    6061        final XPath xPath = XPathFactory.newInstance().newXPath();
    61         for (String page : pages) {
     62        for (String page : distinctPages) {
    6263            String normalized = xPath.evaluate("/api/query/normalized/n[@from='" + page + "']/@to", document);
    6364            if (normalized == null || normalized.isEmpty()) {
Note: See TracChangeset for help on using the changeset viewer.