From 8da3174867b503aae21643ccb032ff43a6647ec3 Mon Sep 17 00:00:00 2001 From: luccioman Date: Tue, 27 Jun 2017 06:42:33 +0200 Subject: [PATCH] Ensure lower case conversion consistency with any default locale. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Especially for Turkish speaking users using "tr" as their system default locale : strings for technical stuff (URLs, tag names, constants...) must not be lower cased with the default locale, as 'I' doesn't becomes 'i' like in other locales such as "en", but becomes 'ı'. --- htroot/ConfigHeuristics_p.java | 3 ++- htroot/Crawler_p.java | 5 +++-- htroot/api/blacklists/add_entry_p.java | 4 +++- htroot/api/blacklists/delete_entry_p.java | 4 +++- htroot/api/getpageinfo_p.java | 3 ++- htroot/api/ymarks/add_ymark.java | 3 ++- .../net/yacy/cora/protocol/RequestHeader.java | 2 +- .../yacy/cora/protocol/http/HTTPClient.java | 3 ++- .../net/yacy/crawler/retrieval/Response.java | 3 ++- source/net/yacy/data/wiki/WikiCode.java | 5 +++-- source/net/yacy/document/Document.java | 21 ++++++++++--------- .../document/content/SurrogateReader.java | 5 +++-- .../parser/html/TransformerWriter.java | 5 +++-- .../parser/rdfa/impl/RDFaTripleImpl.java | 4 +++- source/net/yacy/gui/framework/Browser.java | 3 ++- .../net/yacy/http/AbstractRemoteHandler.java | 3 ++- .../http/servlets/YaCyDefaultServlet.java | 5 +++-- .../kelondro/data/meta/URIMetadataNode.java | 5 +++-- source/net/yacy/kelondro/util/Formatter.java | 2 +- source/net/yacy/kelondro/util/ISO639.java | 7 ++++--- source/net/yacy/kelondro/util/OS.java | 3 ++- source/net/yacy/peers/Network.java | 3 ++- .../net/yacy/peers/operation/yacyRelease.java | 3 ++- source/net/yacy/search/index/Segment.java | 5 +++-- .../net/yacy/search/query/QueryModifier.java | 3 ++- source/net/yacy/search/query/QueryParams.java | 3 ++- .../schema/CollectionConfiguration.java | 7 ++++--- .../yacy/search/schema/CollectionSchema.java | 3 ++- .../yacy/search/schema/WebgraphSchema.java | 3 ++- source/net/yacy/server/serverObjects.java | 3 ++- .../utils/translation/TranslatorXliff.java | 3 ++- source/net/yacy/yacy.java | 15 ++++++------- .../yacy/document/parser/htmlParserTest.java | 6 ++++-- 33 files changed, 95 insertions(+), 60 deletions(-) diff --git a/htroot/ConfigHeuristics_p.java b/htroot/ConfigHeuristics_p.java index c53fee68f..29d3ff2b1 100644 --- a/htroot/ConfigHeuristics_p.java +++ b/htroot/ConfigHeuristics_p.java @@ -39,6 +39,7 @@ import net.yacy.search.Switchboard; import java.io.IOException; import java.net.MalformedURLException; import java.util.Iterator; +import java.util.Locale; import net.yacy.cora.document.id.MultiProtocolURL; import net.yacy.cora.federate.FederateSearchManager; @@ -101,7 +102,7 @@ public class ConfigHeuristics_p { // add new entry to config file final String tmpname = post.get("ossys_newtitle"); if (tmpname != null && tmpurl !=null) { - if (!tmpname.isEmpty() && !tmpurl.isEmpty() && tmpurl.toLowerCase().contains("{searchterms}")) { + if (!tmpname.isEmpty() && !tmpurl.isEmpty() && tmpurl.toLowerCase(Locale.ROOT).contains("{searchterms}")) { /* Check eventual robots.txt policy */ RobotsTxtEntry robotsEntry = null; try { diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java index b8b249688..a747cd52e 100644 --- a/htroot/Crawler_p.java +++ b/htroot/Crawler_p.java @@ -29,6 +29,7 @@ import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; @@ -683,8 +684,8 @@ public class Crawler_p { try { wantedPPM = post.getInt("customPPM", wantedPPM); } catch (final NumberFormatException e) {} - if ("minimum".equals(crawlingPerformance.toLowerCase())) wantedPPM = 10; - if ("maximum".equals(crawlingPerformance.toLowerCase())) wantedPPM = 30000; + if ("minimum".equals(crawlingPerformance.toLowerCase(Locale.ROOT))) wantedPPM = 10; + if ("maximum".equals(crawlingPerformance.toLowerCase(Locale.ROOT))) wantedPPM = 30000; int wPPM = wantedPPM; if ( wPPM <= 0 ) { diff --git a/htroot/api/blacklists/add_entry_p.java b/htroot/api/blacklists/add_entry_p.java index cb135deab..fc157df37 100644 --- a/htroot/api/blacklists/add_entry_p.java +++ b/htroot/api/blacklists/add_entry_p.java @@ -1,3 +1,5 @@ +import java.util.Locale; + import net.yacy.cora.protocol.RequestHeader; import net.yacy.data.ListManager; import net.yacy.data.WorkTables; @@ -25,7 +27,7 @@ public class add_entry_p { ListManager.switchboard.tables.recordAPICall( post, - "add_entry_p." + header.fileType().toString().toLowerCase(), + "add_entry_p." + header.fileType().toString().toLowerCase(Locale.ROOT), WorkTables.TABLE_API_TYPE_CONFIGURATION, "add to blacklist '" + blacklistToUse + "': " + entry); diff --git a/htroot/api/blacklists/delete_entry_p.java b/htroot/api/blacklists/delete_entry_p.java index debf3dc23..9afa3b4f2 100644 --- a/htroot/api/blacklists/delete_entry_p.java +++ b/htroot/api/blacklists/delete_entry_p.java @@ -1,3 +1,5 @@ +import java.util.Locale; + import net.yacy.cora.protocol.RequestHeader; import net.yacy.data.ListManager; import net.yacy.data.WorkTables; @@ -26,7 +28,7 @@ public class delete_entry_p { // store this call as api call ListManager.switchboard.tables.recordAPICall( post, - "delete_entry_p." + header.fileType().toString().toLowerCase(), + "delete_entry_p." + header.fileType().toString().toLowerCase(Locale.ROOT), WorkTables.TABLE_API_TYPE_CONFIGURATION, "delete from blacklist '" + blacklistToUse + "': " + entry); diff --git a/htroot/api/getpageinfo_p.java b/htroot/api/getpageinfo_p.java index 51b6f2bb8..a24f3ccc5 100644 --- a/htroot/api/getpageinfo_p.java +++ b/htroot/api/getpageinfo_p.java @@ -30,6 +30,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Set; import javax.xml.parsers.DocumentBuilder; @@ -116,7 +117,7 @@ public class getpageinfo_p { if (post.containsKey("actions")) actions=post.get("actions"); String url=post.get("url"); - if (url.toLowerCase().startsWith("ftp://")) { + if (url.toLowerCase(Locale.ROOT).startsWith("ftp://")) { prop.put("robots-allowed", "1"); // ok to crawl prop.put("robotsInfo", "ftp does not follow robots.txt"); prop.putXML("title", "FTP: " + url); diff --git a/htroot/api/ymarks/add_ymark.java b/htroot/api/ymarks/add_ymark.java index c11755584..b079ae4f0 100644 --- a/htroot/api/ymarks/add_ymark.java +++ b/htroot/api/ymarks/add_ymark.java @@ -1,4 +1,5 @@ import java.io.IOException; +import java.util.Locale; import net.yacy.cora.document.id.DigestURL; import net.yacy.cora.protocol.ClientIdentification; @@ -51,7 +52,7 @@ public class add_ymark { String url = post.get(YMarkEntry.BOOKMARK.URL.key(),YMarkEntry.BOOKMARK.URL.deflt()); boolean hasProtocol = false; for (final YMarkTables.PROTOCOLS p : YMarkTables.PROTOCOLS.values()) { - if(url.toLowerCase().startsWith(p.protocol())) { + if(url.toLowerCase(Locale.ROOT).startsWith(p.protocol())) { hasProtocol = true; break; } diff --git a/source/net/yacy/cora/protocol/RequestHeader.java b/source/net/yacy/cora/protocol/RequestHeader.java index 8a4b38f55..62f0a0b41 100644 --- a/source/net/yacy/cora/protocol/RequestHeader.java +++ b/source/net/yacy/cora/protocol/RequestHeader.java @@ -129,7 +129,7 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest public FileType fileType() { String path = this.getPathInfo(); if (path == null) return FileType.HTML; - path = path.toLowerCase(); + path = path.toLowerCase(Locale.ROOT); if (path.endsWith(".json")) return FileType.JSON; if (path.endsWith(".xml")) return FileType.XML; if (path.endsWith(".rdf")) return FileType.XML; diff --git a/source/net/yacy/cora/protocol/http/HTTPClient.java b/source/net/yacy/cora/protocol/http/HTTPClient.java index a04acc09d..1f6e94e33 100644 --- a/source/net/yacy/cora/protocol/http/HTTPClient.java +++ b/source/net/yacy/cora/protocol/http/HTTPClient.java @@ -34,6 +34,7 @@ import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Set; @@ -664,7 +665,7 @@ public class HTTPClient { mimeType = contentType.getValue(); if (mimeType != null) { - mimeType = mimeType.trim().toLowerCase(); + mimeType = mimeType.trim().toLowerCase(Locale.ROOT); final int pos = mimeType.indexOf(';'); if(pos >= 0) { diff --git a/source/net/yacy/crawler/retrieval/Response.java b/source/net/yacy/crawler/retrieval/Response.java index e4d1f41d0..fe6b7f244 100644 --- a/source/net/yacy/crawler/retrieval/Response.java +++ b/source/net/yacy/crawler/retrieval/Response.java @@ -28,6 +28,7 @@ package net.yacy.crawler.retrieval; import java.nio.charset.StandardCharsets; import java.util.Date; +import java.util.Locale; import net.yacy.cora.document.analysis.Classification; import net.yacy.cora.document.encoding.ASCII; @@ -787,7 +788,7 @@ public class Response { String mimeType = this.responseHeader.getContentType(); if (mimeType != null) { - mimeType = mimeType.trim().toLowerCase(); + mimeType = mimeType.trim().toLowerCase(Locale.ROOT); final int pos = mimeType.indexOf(';'); return ((pos < 0) ? mimeType : mimeType.substring(0, pos)); diff --git a/source/net/yacy/data/wiki/WikiCode.java b/source/net/yacy/data/wiki/WikiCode.java index 1d5248713..f7b1f2bf4 100644 --- a/source/net/yacy/data/wiki/WikiCode.java +++ b/source/net/yacy/data/wiki/WikiCode.java @@ -30,6 +30,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.regex.Pattern; @@ -1069,7 +1070,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser { } if(closeIndex > 0) { final String content = processedLine.substring(openIndex + LEN_WIKI_OPEN_METADATA, closeIndex); - if (content.toLowerCase().startsWith("coordinate")) { + if (content.toLowerCase(Locale.ROOT).startsWith("coordinate")) { // parse Geographical Coordinates as described in // http://en.wikipedia.org/wiki/Wikipedia:Manual_of_Style_%28dates_and_numbers%29#Geographical_coordinates // looks like: @@ -1087,7 +1088,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser { String name = ""; try { for (final String c : b) { - if (c.toLowerCase().startsWith("name=")) { + if (c.toLowerCase(Locale.ROOT).startsWith("name=")) { name = c.substring(5); } if (c.toUpperCase().startsWith("NS=")) { diff --git a/source/net/yacy/document/Document.java b/source/net/yacy/document/Document.java index eed245baf..e75e84c63 100644 --- a/source/net/yacy/document/Document.java +++ b/source/net/yacy/document/Document.java @@ -44,6 +44,7 @@ import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Matcher; @@ -565,8 +566,8 @@ dc_rights continue; } - final boolean noindex = url.getRelProperty().toLowerCase().indexOf("noindex",0) >= 0; - final boolean nofollow = url.getRelProperty().toLowerCase().indexOf("nofollow",0) >= 0; + final boolean noindex = url.getRelProperty().toLowerCase(Locale.ROOT).indexOf("noindex",0) >= 0; + final boolean nofollow = url.getRelProperty().toLowerCase(Locale.ROOT).indexOf("nofollow",0) >= 0; if ((thishost == null && url.getHost() == null) || ((thishost != null && url.getHost() != null) && (url.getHost().endsWith(thishost) || @@ -578,9 +579,9 @@ dc_rights extpos = u.lastIndexOf('.'); if (extpos > 0) { if (((qpos = u.indexOf('?')) >= 0) && (qpos > extpos)) { - ext = u.substring(extpos + 1, qpos).toLowerCase(); + ext = u.substring(extpos + 1, qpos).toLowerCase(Locale.ROOT); } else { - ext = u.substring(extpos + 1).toLowerCase(); + ext = u.substring(extpos + 1).toLowerCase(Locale.ROOT); } if (Classification.isMediaExtension(ext)) { // this is not a normal anchor, its a media link @@ -705,10 +706,10 @@ dc_rights u = url.toNormalform(true); // find start of a referenced http url - if ((pos = u.toLowerCase().indexOf("http://", 7)) > 0) { // 7 = skip the protocol part of the source url + if ((pos = u.toLowerCase(Locale.ROOT).indexOf("http://", 7)) > 0) { // 7 = skip the protocol part of the source url i.remove(); u = u.substring(pos); - while ((pos = u.toLowerCase().indexOf("http://", 7)) > 0) + while ((pos = u.toLowerCase(Locale.ROOT).indexOf("http://", 7)) > 0) u = u.substring(pos); url = new AnchorURL(u); if (!(v.containsKey(url))) @@ -717,10 +718,10 @@ dc_rights } // find start of a referenced https url - if ((pos = u.toLowerCase().indexOf("https://", 7)) > 0) { // 7 = skip the protocol part of the source url + if ((pos = u.toLowerCase(Locale.ROOT).indexOf("https://", 7)) > 0) { // 7 = skip the protocol part of the source url i.remove(); u = u.substring(pos); - while ((pos = u.toLowerCase().indexOf("https://", 7)) > 0) + while ((pos = u.toLowerCase(Locale.ROOT).indexOf("https://", 7)) > 0) u = u.substring(pos); url = new AnchorURL(u); if (!(v.containsKey(url))) @@ -728,10 +729,10 @@ dc_rights continue loop; } - if ((pos = u.toLowerCase().indexOf("/www.", 11)) > 0) { // 11 = skip protocol part + www of source url "http://www." + if ((pos = u.toLowerCase(Locale.ROOT).indexOf("/www.", 11)) > 0) { // 11 = skip protocol part + www of source url "http://www." i.remove(); u = url.getProtocol()+":/" + u.substring(pos); - while ((pos = u.toLowerCase().indexOf("/www.", 11)) > 0) + while ((pos = u.toLowerCase(Locale.ROOT).indexOf("/www.", 11)) > 0) u = url.getProtocol()+":/" + u.substring(pos); AnchorURL addurl = new AnchorURL(u); diff --git a/source/net/yacy/document/content/SurrogateReader.java b/source/net/yacy/document/content/SurrogateReader.java index ff0524d2f..8f23ebca6 100644 --- a/source/net/yacy/document/content/SurrogateReader.java +++ b/source/net/yacy/document/content/SurrogateReader.java @@ -32,6 +32,7 @@ import java.io.PushbackInputStream; import java.io.StringReader; import java.net.MalformedURLException; import java.nio.charset.StandardCharsets; +import java.util.Locale; import java.util.Map; import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.BlockingQueue; @@ -220,7 +221,7 @@ public class SurrogateReader extends DefaultHandler implements Runnable { @Override public void startElement(final String uri, final String name, String tag, final Attributes atts) throws SAXException { if (tag == null) return; - tag = tag.toLowerCase(); + tag = tag.toLowerCase(Locale.ROOT); if ("record".equals(tag) || "document".equals(tag) || "doc".equals(tag)) { this.dcEntry = new DCEntry(); } else if ("element".equals(tag) || "str".equals(tag) || "int".equals(tag) || "bool".equals(tag) || "long".equals(tag)) { @@ -239,7 +240,7 @@ public class SurrogateReader extends DefaultHandler implements Runnable { @Override public void endElement(final String uri, final String name, String tag) { if (tag == null) return; - tag = tag.toLowerCase(); + tag = tag.toLowerCase(Locale.ROOT); if ("record".equals(tag) || "document".equals(tag) || "doc".equals(tag)) { try { // check if url is in accepted domain diff --git a/source/net/yacy/document/parser/html/TransformerWriter.java b/source/net/yacy/document/parser/html/TransformerWriter.java index 8c745cdbc..202c6186d 100644 --- a/source/net/yacy/document/parser/html/TransformerWriter.java +++ b/source/net/yacy/document/parser/html/TransformerWriter.java @@ -37,6 +37,7 @@ import java.io.OutputStreamWriter; import java.io.Writer; import java.nio.charset.Charset; import java.util.Enumeration; +import java.util.Locale; import java.util.Properties; import java.util.Stack; import net.yacy.document.parser.html.ContentScraper.TagName; @@ -194,7 +195,7 @@ public final class TransformerWriter extends Writer { if (in[1] == '/') { // a closing tag tagend = tagEnd(in, 2); - tag = new String(in, 2, tagend - 2).toLowerCase(); + tag = new String(in, 2, tagend - 2).toLowerCase(Locale.ROOT); final char[] text = new char[in.length - tagend - 1]; System.arraycopy(in, tagend, text, 0, in.length - tagend - 1); return filterTag(text, quotechar, tag, false); @@ -207,7 +208,7 @@ public final class TransformerWriter extends Writer { // an opening tag tagend = tagEnd(in, 1); - tag = new String(in, 1, tagend - 1).toLowerCase(); + tag = new String(in, 1, tagend - 1).toLowerCase(Locale.ROOT); final char[] text = new char[in.length - tagend - 1]; System.arraycopy(in, tagend, text, 0, in.length - tagend - 1); return filterTag(text, quotechar, tag, true); diff --git a/source/net/yacy/document/parser/rdfa/impl/RDFaTripleImpl.java b/source/net/yacy/document/parser/rdfa/impl/RDFaTripleImpl.java index a1998efa8..c852f0ecb 100644 --- a/source/net/yacy/document/parser/rdfa/impl/RDFaTripleImpl.java +++ b/source/net/yacy/document/parser/rdfa/impl/RDFaTripleImpl.java @@ -5,6 +5,8 @@ import java.io.File; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; +import java.util.Locale; + import javax.xml.transform.Templates; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; @@ -38,7 +40,7 @@ public class RDFaTripleImpl{ BufferedReader bufReader = new BufferedReader(in); bufReader.mark(2048); // mark position for following reset String readLine = bufReader.readLine(); - if (!readLine.toLowerCase().contains(" https://reverseProxy/yacyURL -> http://yacypeer/yacyURL * In that case, absolute URLs rendered by this peer (in rss feeds for example) must effectively start with the https scheme */ - protocolHeader = header.get(HttpHeaders.X_FORWARDED_PROTO.toString(), "").toLowerCase(); + protocolHeader = header.get(HttpHeaders.X_FORWARDED_PROTO.toString(), "").toLowerCase(Locale.ROOT); /* Here we only allow an upgrade from HTTP to HTTPS, not the reverse (we don't want a forged HTTP header by an eventual attacker to force fallback to HTTP) */ if("https".equals(protocolHeader)) { diff --git a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java index 5ca31c85a..f63c80a6a 100644 --- a/source/net/yacy/kelondro/data/meta/URIMetadataNode.java +++ b/source/net/yacy/kelondro/data/meta/URIMetadataNode.java @@ -34,6 +34,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Properties; import java.util.Set; import java.util.regex.Pattern; @@ -264,7 +265,7 @@ public class URIMetadataNode extends SolrDocument /* implements Comparable= 0) extension = extension.substring(0,extension.indexOf(';')); @@ -632,7 +633,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri String robots_meta = html.getMetas().get("robots"); // this tag may have values: all, index, noindex, nofollow; see http://www.robotstxt.org/meta.html if (robots_meta != null) { - robots_meta = robots_meta.toLowerCase(); + robots_meta = robots_meta.toLowerCase(Locale.ROOT); if (robots_meta.indexOf("all",0) >= 0) b += 1; // set bit 0 if (robots_meta.indexOf("index",0) == 0 || robots_meta.indexOf(" index",0) >= 0 || robots_meta.indexOf(",index",0) >= 0 ) b += 2; // set bit 1 if (robots_meta.indexOf("follow",0) == 0 || robots_meta.indexOf(" follow",0) >= 0 || robots_meta.indexOf(",follow",0) >= 0 ) b += 4; // set bit 2 @@ -2166,7 +2167,7 @@ public class CollectionConfiguration extends SchemaConfiguration implements Seri List il = new ArrayList(rel.size()); for (final String s: rel) { int i = 0; - final String s0 = s.toLowerCase().trim(); + final String s0 = s.toLowerCase(Locale.ROOT).trim(); if ("me".equals(s0)) i += 1; if ("nofollow".equals(s0)) i += 2; il.add(i); diff --git a/source/net/yacy/search/schema/CollectionSchema.java b/source/net/yacy/search/schema/CollectionSchema.java index 52a35e1b1..cdaf114c7 100644 --- a/source/net/yacy/search/schema/CollectionSchema.java +++ b/source/net/yacy/search/schema/CollectionSchema.java @@ -22,6 +22,7 @@ package net.yacy.search.schema; import java.util.Date; import java.util.List; +import java.util.Locale; import net.yacy.cora.federate.solr.SchemaDeclaration; import net.yacy.cora.federate.solr.SolrType; @@ -322,7 +323,7 @@ public enum CollectionSchema implements SchemaDeclaration { public final void setSolrFieldName(String theValue) { // make sure no empty string is assigned if ( (theValue != null) && (!theValue.isEmpty()) ) { - this.solrFieldName = theValue.toLowerCase(); + this.solrFieldName = theValue.toLowerCase(Locale.ROOT); } else { this.solrFieldName = null; } diff --git a/source/net/yacy/search/schema/WebgraphSchema.java b/source/net/yacy/search/schema/WebgraphSchema.java index 9f4b6ad55..bd16245a1 100644 --- a/source/net/yacy/search/schema/WebgraphSchema.java +++ b/source/net/yacy/search/schema/WebgraphSchema.java @@ -22,6 +22,7 @@ package net.yacy.search.schema; import java.util.Date; import java.util.List; +import java.util.Locale; import net.yacy.cora.federate.solr.SchemaDeclaration; import net.yacy.cora.federate.solr.SolrType; @@ -155,7 +156,7 @@ public enum WebgraphSchema implements SchemaDeclaration { public final void setSolrFieldName(String theValue) { // make sure no empty string is assigned if ( (theValue != null) && (!theValue.isEmpty()) ) { - this.solrFieldName = theValue.toLowerCase(); + this.solrFieldName = theValue.toLowerCase(Locale.ROOT); } else { this.solrFieldName = null; } diff --git a/source/net/yacy/server/serverObjects.java b/source/net/yacy/server/serverObjects.java index 68090c51f..39dc76515 100644 --- a/source/net/yacy/server/serverObjects.java +++ b/source/net/yacy/server/serverObjects.java @@ -55,6 +55,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.regex.Pattern; @@ -480,7 +481,7 @@ public class serverObjects implements Serializable, Cloneable { public boolean getBoolean(final String key) { String s = removeByteOrderMark(get(key)); if (s == null) return false; - s = s.toLowerCase(); + s = s.toLowerCase(Locale.ROOT); return s.equals("true") || s.equals("on") || s.equals("1"); } diff --git a/source/net/yacy/utils/translation/TranslatorXliff.java b/source/net/yacy/utils/translation/TranslatorXliff.java index 534433f71..a95c1d857 100644 --- a/source/net/yacy/utils/translation/TranslatorXliff.java +++ b/source/net/yacy/utils/translation/TranslatorXliff.java @@ -34,6 +34,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import java.util.LinkedHashMap; +import java.util.Locale; import java.util.Map; import java.util.TreeMap; import javax.xml.stream.XMLInputFactory; @@ -163,7 +164,7 @@ public class TranslatorXliff extends Translator { @Override public Map> loadTranslationsLists(final File xliffFile) { File locallng = getScratchFile(xliffFile); - if (xliffFile.getName().toLowerCase().endsWith(".xlf") || xliffFile.getName().toLowerCase().endsWith(".xliff")) { + if (xliffFile.getName().toLowerCase(Locale.ROOT).endsWith(".xlf") || xliffFile.getName().toLowerCase(Locale.ROOT).endsWith(".xliff")) { if (locallng.exists()) { Map> mergedList = loadTranslationsListsFromXliff(xliffFile); Map> tmplist = loadTranslationsListsFromXliff(locallng); diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java index 4c4690e32..052546161 100644 --- a/source/net/yacy/yacy.java +++ b/source/net/yacy/yacy.java @@ -40,6 +40,7 @@ import java.nio.channels.FileLock; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.concurrent.Semaphore; @@ -780,7 +781,7 @@ public final class yacy { // exception : if the -gui option is used then do not go into headless mode since that uses a gui boolean headless = true; if (OS.isWindows) headless = false; - if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) headless = false; + if (args.length >= 1 && args[0].toLowerCase(Locale.ROOT).equals("-gui")) headless = false; System.setProperty("java.awt.headless", headless ? "true" : "false"); String s = ""; for (final String a: args) s += a + " "; @@ -790,32 +791,32 @@ public final class yacy { File dataRoot = applicationRoot; //System.out.println("args.length=" + args.length); //System.out.print("args=["); for (int i = 0; i < args.length; i++) System.out.print(args[i] + ", "); System.out.println("]"); - if ((args.length >= 1) && (args[0].toLowerCase().equals("-startup") || args[0].equals("-start"))) { + if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-startup") || args[0].equals("-start"))) { // normal start-up of yacy if (args.length > 1) { dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); } preReadSavedConfigandInit(dataRoot); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, false); - } else if (args.length >= 1 && args[0].toLowerCase().equals("-gui")) { + } else if (args.length >= 1 && args[0].toLowerCase(Locale.ROOT).equals("-gui")) { // start-up of yacy with gui if (args.length > 1) { dataRoot = new File(System.getProperty("user.home").replace('\\', '/'), args[1]); } preReadSavedConfigandInit(dataRoot); startup(dataRoot, applicationRoot, startupMemFree, startupMemTotal, true); - } else if ((args.length >= 1) && ((args[0].toLowerCase().equals("-shutdown")) || (args[0].equals("-stop")))) { + } else if ((args.length >= 1) && ((args[0].toLowerCase(Locale.ROOT).equals("-shutdown")) || (args[0].equals("-stop")))) { // normal shutdown of yacy if (args.length == 2) applicationRoot= new File(args[1]); shutdown(applicationRoot); - } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-update"))) { + } else if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-update"))) { // aut-update yacy if (args.length == 2) applicationRoot= new File(args[1]); update(applicationRoot); - } else if ((args.length >= 1) && (args[0].toLowerCase().equals("-version"))) { + } else if ((args.length >= 1) && (args[0].toLowerCase(Locale.ROOT).equals("-version"))) { // show yacy version System.out.println(copyright); - } else if ((args.length > 1) && (args[0].toLowerCase().equals("-config"))) { + } else if ((args.length > 1) && (args[0].toLowerCase(Locale.ROOT).equals("-config"))) { // set config parameter. Special handling of adminAccount=user:pwd (generates md5 encoded password) // on Windows parameter should be enclosed in doublequotes to accept = sign (e.g. -config "port=8090" "port.ssl=8043") File f = new File (dataRoot,"DATA/SETTINGS/"); diff --git a/test/java/net/yacy/document/parser/htmlParserTest.java b/test/java/net/yacy/document/parser/htmlParserTest.java index a57c5b1c7..beb554a80 100644 --- a/test/java/net/yacy/document/parser/htmlParserTest.java +++ b/test/java/net/yacy/document/parser/htmlParserTest.java @@ -8,6 +8,8 @@ import java.net.MalformedURLException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Locale; + import junit.framework.TestCase; import net.yacy.cora.document.id.AnchorURL; import net.yacy.document.Document; @@ -40,13 +42,13 @@ public class htmlParserTest extends TestCase { for (int i=0; i < testStrings.length; i++) { // desired conversion result String shouldBe = testStrings[i][1]; - shouldBe = shouldBe!=null ? shouldBe.toLowerCase() : null; + shouldBe = shouldBe!=null ? shouldBe.toLowerCase(Locale.ROOT) : null; // conversion result String charset = htmlParser.patchCharsetEncoding(testStrings[i][0]); // test if equal - assertEquals(shouldBe, charset!=null ? charset.toLowerCase() : null); + assertEquals(shouldBe, charset!=null ? charset.toLowerCase(Locale.ROOT) : null); System.out.println("testGetRealCharsetEncoding: " + (testStrings[i][0]!=null?testStrings[i][0]:"null") + " -> " + (charset!=null?charset:"null") + " | Supported: " + (charset!=null?Charset.isSupported(charset):false)); }