Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repositories {
}

dependencies {
implementation("com.github.stormcloakgames:jStyleParser:1.0.0")
implementation("com.github.stormcloakgames:jStyleParser:1.0.1")
implementation(libs.org.htmlunit.neko.htmlunit)
implementation(libs.org.slf4j.slf4j.api)
testImplementation(libs.junit.junit)
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/fit/cssbox/awt/GraphicsVisualContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.fit.cssbox.css.CSSUnits;
Expand Down Expand Up @@ -281,7 +282,7 @@ protected String getFallbackFont()
{
for (int i = 0; i < avail.length; i++)
{
if (avail[i].toLowerCase().contains("sans") || avail[i].toLowerCase().contains("serif"))
if (avail[i].toLowerCase(Locale.ROOT).contains("sans") || avail[i].toLowerCase(Locale.ROOT).contains("serif"))
{
ret = avail[i];
break;
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/org/fit/cssbox/css/FontSpec.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package org.fit.cssbox.css;

import java.util.Locale;

import cz.vutbr.web.css.CSSProperty;
import cz.vutbr.web.css.CSSProperty.FontStyle;
import cz.vutbr.web.css.CSSProperty.FontWeight;
Expand Down Expand Up @@ -76,7 +78,7 @@ public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + ((family == null) ? 0 : family.toLowerCase().hashCode());
result = prime * result + ((family == null) ? 0 : family.toLowerCase(Locale.ROOT).hashCode());
result = prime * result + ((style == null) ? 0 : style.hashCode());
result = prime * result + ((weight == null) ? 0 : weight.hashCode());
return result;
Expand All @@ -93,7 +95,7 @@ public boolean equals(Object obj)
{
if (other.family != null) return false;
}
else if (!family.toLowerCase().equals(other.family.toLowerCase())) return false;
else if (!family.toLowerCase(Locale.ROOT).equals(other.family.toLowerCase(Locale.ROOT))) return false;
if (style != other.style) return false;
if (weight != other.weight) return false;
return true;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/fit/cssbox/css/HTMLNorm.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package org.fit.cssbox.css;

import java.util.Locale;
import java.util.Vector;

import cz.vutbr.web.css.CSSFactory;
Expand Down Expand Up @@ -64,7 +65,7 @@ public static void attributesToStyles(Node n, String tab_inh)
if (n.getNodeType() == Node.ELEMENT_NODE)
{
final Element el = (Element) n;
final String tagname = el.getTagName().toLowerCase();
final String tagname = el.getTagName().toLowerCase(Locale.ROOT);
//Analyze HTML attributes
String attrs = "";
//background
Expand Down Expand Up @@ -124,9 +125,9 @@ public static void attributesToStyles(Node n, String tab_inh)
}
}
if (el.getAttributes().getNamedItem("frame") != null)
frame = el.getAttribute("frame").toLowerCase();
frame = el.getAttribute("frame").toLowerCase(Locale.ROOT);
if (el.getAttributes().getNamedItem("rules") != null)
rules = el.getAttribute("rules").toLowerCase();
rules = el.getAttribute("rules").toLowerCase(Locale.ROOT);

if (!border.equals("0"))
{
Expand Down Expand Up @@ -323,7 +324,7 @@ else if (sz.startsWith("-"))
*/
public static float computeAttributeLength(String value, float whole) throws NumberFormatException
{
String sval = value.trim().toLowerCase();
String sval = value.trim().toLowerCase(Locale.ROOT);
if (sval.endsWith("%"))
{
float val = Float.parseFloat(sval.substring(0, sval.length() - 1));
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/fit/cssbox/io/DOMSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.fit.cssbox.io;

import java.io.IOException;
import java.util.Locale;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -55,7 +56,7 @@ public void setContentType(String type)
{
if (type != null)
{
String t = type.toLowerCase();
String t = type.toLowerCase(Locale.ROOT);

//extract the charset if specified
int strt = t.indexOf("charset=");
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/fit/cssbox/layout/BrowserConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.fit.cssbox.io.ContentObserver;
Expand Down Expand Up @@ -359,7 +360,7 @@ public DOMSource createDOMSource(DocumentSource src)
*/
public void setLogicalFont(String logical, List<String> physical)
{
logicalFonts.put(logical.toLowerCase(), physical);
logicalFonts.put(logical.toLowerCase(Locale.ROOT), physical);
}

/**
Expand All @@ -369,7 +370,7 @@ public void setLogicalFont(String logical, List<String> physical)
*/
public List<String> getLogicalFont(String logical)
{
List<String> ret = logicalFonts.get(logical.toLowerCase());
List<String> ret = logicalFonts.get(logical.toLowerCase(Locale.ROOT));
if (ret == null)
ret = Collections.emptyList();
return ret;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/org/fit/cssbox/layout/HTMLBoxFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.net.URL;
import java.net.URLDecoder;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

import cz.vutbr.web.css.NodeData;
Expand Down Expand Up @@ -70,12 +71,12 @@ public HTMLBoxFactory(BoxFactory parent)
*/
public boolean isTagSupported(Element e)
{
if (e.getNodeName() != null && supported.contains(e.getNodeName().toLowerCase())) //completely supported tags
if (e.getNodeName() != null && supported.contains(e.getNodeName().toLowerCase(Locale.ROOT))) //completely supported tags
return true;
else //special cases
{
//empty anchor elements must be preserved
if (e.getNodeName().toLowerCase().equals("a") && e.hasAttribute("name")
if (e.getNodeName().toLowerCase(Locale.ROOT).equals("a") && e.hasAttribute("name")
&& (e.getTextContent() == null || e.getTextContent().trim().length() == 0))
return true;
else
Expand All @@ -94,7 +95,7 @@ public boolean isTagSupported(Element e)
*/
public ElementBox createBox(ElementBox parent, Element e, Viewport viewport, NodeData style)
{
String name = e.getNodeName().toLowerCase();
String name = e.getNodeName().toLowerCase(Locale.ROOT);
if (name.equals("object"))
return createSubtreeObject(parent, e, viewport, style);
else if (name.equals("img"))
Expand Down Expand Up @@ -163,7 +164,7 @@ protected ElementBox createSubtreeObject(ElementBox parent, Element e, Viewport
//try to create the content object based on the mime type
try
{
String mime = HTMLNorm.getAttribute(e, "type").toLowerCase();
String mime = HTMLNorm.getAttribute(e, "type").toLowerCase(Locale.ROOT);
String cb = HTMLNorm.getAttribute(e, "codebase");
String dataurl = URLDecoder.decode(HTMLNorm.getAttribute(e, "data"), "UTF-8");
URL base = new URL(factory.getBaseURL(), cb);
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/fit/cssbox/layout/ListItemBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
package org.fit.cssbox.layout;

import java.util.Locale;

import org.w3c.dom.Element;

import cz.vutbr.web.css.CSSProperty;
Expand Down Expand Up @@ -195,7 +197,7 @@ public static String formatItemNumber(int itemNumber, ListStyleType styleType)
text = binaryToRoman(itemNumber);
break;
case LOWER_ROMAN:
text = binaryToRoman(itemNumber).toLowerCase();
text = binaryToRoman(itemNumber).toLowerCase(Locale.ROOT);
break;
default:
text = String.valueOf(itemNumber); // default decimal
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/fit/cssbox/layout/TextBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
package org.fit.cssbox.layout;

import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

import org.w3c.dom.Text;
Expand Down Expand Up @@ -303,9 +304,9 @@ private String applyTransformations(String src)
switch (transform)
{
case LOWERCASE:
return src.toLowerCase();
return src.toLowerCase(Locale.ROOT);
case UPPERCASE:
return src.toUpperCase();
return src.toUpperCase(Locale.ROOT);
case CAPITALIZE:
StringBuilder ret = new StringBuilder(src.length());
boolean ws = true;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/fit/cssbox/testing/TestBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.Callable;
Expand Down Expand Up @@ -147,7 +148,7 @@ private void parseToc()
for (int ti = 0; ti < tags.getLength(); ti++)
{
Element tag = (Element) tags.item(ti);
entry.tags.add(tag.getTextContent().trim().toLowerCase());
entry.tags.add(tag.getTextContent().trim().toLowerCase(Locale.ROOT));
}

tests.add(entry);
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/fit/cssbox/test/ReferenceComparisonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Map;

import org.fit.cssbox.testing.ReferenceResults;
Expand Down Expand Up @@ -91,4 +92,13 @@ public void checkForRegressions() throws MalformedURLException
Assert.assertTrue("All results passed", errorcnt <= 5);
}

@Test
public void testTurkishLocale() throws MalformedURLException
{
Locale.setDefault(new Locale("tr", "TR"));

checkForRegressions();

Locale.setDefault(Locale.ROOT);
}
}
Loading