Skip to content

Commit b64bc34

Browse files
committed
Make lower/upper casing locale independent
DEVSIX-9092
1 parent a9e085a commit b64bc34

File tree

6 files changed

+13
-7
lines changed

6 files changed

+13
-7
lines changed

src/main/java/com/itextpdf/html2pdf/attach/impl/tags/HTagWorker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.html2pdf.attach.impl.tags;
2424

25+
import com.itextpdf.commons.utils.StringNormalizer;
2526
import com.itextpdf.html2pdf.attach.ProcessorContext;
2627
import com.itextpdf.layout.tagging.IAccessibleElement;
2728
import com.itextpdf.layout.IPropertyContainer;
@@ -42,7 +43,7 @@ public class HTagWorker extends DivTagWorker {
4243
*/
4344
public HTagWorker(IElementNode element, ProcessorContext context) {
4445
super(element, context);
45-
this.role = element.name().toUpperCase();
46+
this.role = StringNormalizer.toUpperCase(element.name());
4647
}
4748

4849
@Override

src/main/java/com/itextpdf/html2pdf/attach/impl/tags/MetaTagWorker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.html2pdf.attach.impl.tags;
2424

25+
import com.itextpdf.commons.utils.StringNormalizer;
2526
import com.itextpdf.html2pdf.attach.ITagWorker;
2627
import com.itextpdf.html2pdf.attach.ProcessorContext;
2728
import com.itextpdf.kernel.pdf.PdfDocumentInfo;
@@ -52,7 +53,7 @@ public void processEnd(IElementNode element, ProcessorContext context) {
5253
// Note that charset and http-equiv attributes are processed on DataUtil#parseByteData(ByteBuffer, String, String, Parser) level.
5354
String name = element.getAttribute(AttributeConstants.NAME);
5455
if (null != name) {
55-
name = name.toLowerCase();
56+
name = StringNormalizer.toLowerCase(name);
5657
String content = element.getAttribute(AttributeConstants.CONTENT);
5758
// although iText do not visit head during processing html to elements
5859
// meta tag can by accident be presented in body section and that shouldn't cause NPE

src/main/java/com/itextpdf/html2pdf/attach/util/WaitingInlineElementsHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public WaitingInlineElementsHelper(String whiteSpace, String textTransform) {
9393
public void add(String text) {
9494
text = WhiteSpaceUtil.processWhitespaces(text, keepLineBreaks, collapseSpaces);
9595

96+
// Here we intentionally use locale dependent toLowerCase/toUpperCase
9697
if (CssConstants.UPPERCASE.equals(textTransform)) {
9798
text = text.toUpperCase();
9899
} else if (CssConstants.LOWERCASE.equals(textTransform)) {

src/main/java/com/itextpdf/html2pdf/css/apply/util/TransformationApplierUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.html2pdf.css.apply.util;
2424

25+
import com.itextpdf.commons.utils.StringNormalizer;
2526
import com.itextpdf.html2pdf.attach.ProcessorContext;
2627
import com.itextpdf.html2pdf.css.CssConstants;
2728
import com.itextpdf.layout.IPropertyContainer;
@@ -58,7 +59,7 @@ private TransformationApplierUtil() {
5859
public static void applyTransformation(Map<String, String> cssProps, ProcessorContext context, IPropertyContainer element) {
5960
String transformationFunction;
6061
if (cssProps.get(CssConstants.TRANSFORM) != null)
61-
transformationFunction = cssProps.get(CssConstants.TRANSFORM).toLowerCase();
62+
transformationFunction = StringNormalizer.toLowerCase(cssProps.get(CssConstants.TRANSFORM));
6263
else
6364
return;
6465
String[] components = transformationFunction.split("\\)");

src/main/java/com/itextpdf/html2pdf/html/HtmlUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.html2pdf.html;
2424

25+
import com.itextpdf.commons.utils.StringNormalizer;
2526
import com.itextpdf.html2pdf.css.CssConstants;
2627
import com.itextpdf.html2pdf.css.resolve.func.counter.CounterDigitsGlyphStyle;
2728
import com.itextpdf.kernel.numbering.ArmenianNumbering;
@@ -162,15 +163,15 @@ public static String getAllNumberGlyphsForStyle(CounterDigitsGlyphStyle glyphSty
162163
case CIRCLE:
163164
return CIRCLE_SYMBOL;
164165
case UPPER_ALPHA_AND_LATIN:
165-
return LATIN_NUMERALS.toUpperCase();
166+
return StringNormalizer.toUpperCase(LATIN_NUMERALS);
166167
case LOWER_ALPHA_AND_LATIN:
167168
return LATIN_NUMERALS;
168169
case LOWER_GREEK:
169170
return GREEK_NUMERALS;
170171
case LOWER_ROMAN:
171172
return ROMAN_NUMERALS;
172173
case UPPER_ROMAN:
173-
return ROMAN_NUMERALS.toUpperCase();
174+
return StringNormalizer.toUpperCase(ROMAN_NUMERALS);
174175
case GEORGIAN:
175176
return GEORGIAN_NUMERALS;
176177
case ARMENIAN:

src/test/java/com/itextpdf/html2pdf/element/InputTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This file is part of the iText (R) project.
2222
*/
2323
package com.itextpdf.html2pdf.element;
2424

25+
import com.itextpdf.commons.utils.StringNormalizer;
2526
import com.itextpdf.forms.form.element.InputField;
2627
import com.itextpdf.forms.logs.FormsLogMessageConstants;
2728
import com.itextpdf.html2pdf.ConverterProperties;
@@ -377,9 +378,9 @@ private void runPDFATest(String name) throws IOException, InterruptedException {
377378
private static class CustomTextInputTagWorkerFactory extends DefaultTagWorkerFactory {
378379
@Override
379380
public ITagWorker getCustomTagWorker(IElementNode tag, ProcessorContext context) {
380-
switch (tag.name().toLowerCase()) {
381+
switch (StringNormalizer.toLowerCase(tag.name())) {
381382
case "input":
382-
switch (tag.getAttribute("type").toLowerCase()) {
383+
switch (StringNormalizer.toLowerCase(tag.getAttribute("type"))) {
383384
case "text":
384385
Map<String, String> map = new HashMap<String, String>();
385386
map.put("page-break-inside", "avoid");

0 commit comments

Comments
 (0)