Skip to content

Commit ef22669

Browse files
vitali-priText-CI
authored andcommitted
Make lower/upper casing locale independent
DEVSIX-9092 Autoported commit. Original commit hash: [b64bc3470]
1 parent 567fdb1 commit ef22669

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/element/InputTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You should have received a copy of the GNU Affero General Public License
2323
using System;
2424
using System.Collections.Generic;
2525
using System.IO;
26+
using iText.Commons.Utils;
2627
using iText.Forms.Form.Element;
2728
using iText.Forms.Logs;
2829
using iText.Html2pdf;
@@ -352,9 +353,9 @@ private void RunPDFATest(String name) {
352353

353354
private class CustomTextInputTagWorkerFactory : DefaultTagWorkerFactory {
354355
public override ITagWorker GetCustomTagWorker(IElementNode tag, ProcessorContext context) {
355-
switch (tag.Name().ToLowerInvariant()) {
356+
switch (StringNormalizer.ToLowerCase(tag.Name())) {
356357
case "input": {
357-
switch (tag.GetAttribute("type").ToLowerInvariant()) {
358+
switch (StringNormalizer.ToLowerCase(tag.GetAttribute("type"))) {
358359
case "text": {
359360
IDictionary<String, String> map = new Dictionary<String, String>();
360361
map.Put("page-break-inside", "avoid");

itext/itext.html2pdf/itext/html2pdf/attach/impl/tags/HTagWorker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
2323
using System;
24+
using iText.Commons.Utils;
2425
using iText.Html2pdf.Attach;
2526
using iText.Layout;
2627
using iText.Layout.Tagging;
@@ -44,7 +45,7 @@ public class HTagWorker : DivTagWorker {
4445
/// <param name="context">the context</param>
4546
public HTagWorker(IElementNode element, ProcessorContext context)
4647
: base(element, context) {
47-
this.role = element.Name().ToUpperInvariant();
48+
this.role = StringNormalizer.ToUpperCase(element.Name());
4849
}
4950

5051
public override void ProcessEnd(IElementNode element, ProcessorContext context) {

itext/itext.html2pdf/itext/html2pdf/attach/impl/tags/MetaTagWorker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
2323
using System;
24+
using iText.Commons.Utils;
2425
using iText.Html2pdf.Attach;
2526
using iText.Html2pdf.Html;
2627
using iText.Kernel.Pdf;
@@ -51,7 +52,7 @@ public virtual void ProcessEnd(IElementNode element, ProcessorContext context) {
5152
// Note that charset and http-equiv attributes are processed on DataUtil#parseByteData(ByteBuffer, String, String, Parser) level.
5253
String name = element.GetAttribute(AttributeConstants.NAME);
5354
if (null != name) {
54-
name = name.ToLowerInvariant();
55+
name = StringNormalizer.ToLowerCase(name);
5556
String content = element.GetAttribute(AttributeConstants.CONTENT);
5657
// although iText do not visit head during processing html to elements
5758
// meta tag can by accident be presented in body section and that shouldn't cause NPE

itext/itext.html2pdf/itext/html2pdf/attach/util/WaitingInlineElementsHelper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public WaitingInlineElementsHelper(String whiteSpace, String textTransform) {
6666
/// <param name="text">the text</param>
6767
public virtual void Add(String text) {
6868
text = WhiteSpaceUtil.ProcessWhitespaces(text, keepLineBreaks, collapseSpaces);
69+
// Here we intentionally use locale dependent toLowerCase/toUpperCase
6970
if (CssConstants.UPPERCASE.Equals(textTransform)) {
7071
text = text.ToUpperInvariant();
7172
}

itext/itext.html2pdf/itext/html2pdf/css/apply/util/TransformationApplierUtil.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ You should have received a copy of the GNU Affero General Public License
2222
*/
2323
using System;
2424
using System.Collections.Generic;
25+
using iText.Commons.Utils;
2526
using iText.Html2pdf.Attach;
2627
using iText.Html2pdf.Css;
2728
using iText.IO.Util;
@@ -48,7 +49,7 @@ public static void ApplyTransformation(IDictionary<String, String> cssProps, Pro
4849
element) {
4950
String transformationFunction;
5051
if (cssProps.Get(CssConstants.TRANSFORM) != null) {
51-
transformationFunction = cssProps.Get(CssConstants.TRANSFORM).ToLowerInvariant();
52+
transformationFunction = StringNormalizer.ToLowerCase(cssProps.Get(CssConstants.TRANSFORM));
5253
}
5354
else {
5455
return;

itext/itext.html2pdf/itext/html2pdf/html/HtmlUtils.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ You should have received a copy of the GNU Affero General Public License
2121
along with this program. If not, see <https://www.gnu.org/licenses/>.
2222
*/
2323
using System;
24+
using iText.Commons.Utils;
2425
using iText.Html2pdf.Css;
2526
using iText.Html2pdf.Css.Resolve.Func.Counter;
2627
using iText.Kernel.Numbering;
@@ -163,7 +164,7 @@ public static String GetAllNumberGlyphsForStyle(CounterDigitsGlyphStyle glyphSty
163164
}
164165

165166
case CounterDigitsGlyphStyle.UPPER_ALPHA_AND_LATIN: {
166-
return LATIN_NUMERALS.ToUpperInvariant();
167+
return StringNormalizer.ToUpperCase(LATIN_NUMERALS);
167168
}
168169

169170
case CounterDigitsGlyphStyle.LOWER_ALPHA_AND_LATIN: {
@@ -179,7 +180,7 @@ public static String GetAllNumberGlyphsForStyle(CounterDigitsGlyphStyle glyphSty
179180
}
180181

181182
case CounterDigitsGlyphStyle.UPPER_ROMAN: {
182-
return ROMAN_NUMERALS.ToUpperInvariant();
183+
return StringNormalizer.ToUpperCase(ROMAN_NUMERALS);
183184
}
184185

185186
case CounterDigitsGlyphStyle.GEORGIAN: {

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a9e085a9269baebf4c48a4bd957eb67c44f324b9
1+
b64bc3470577d3f81c78f8518841f473bb5e4f30

0 commit comments

Comments
 (0)