Skip to content

Commit 23388ca

Browse files
yulian-gaponenkoiText-CI
authored andcommitted
Support exponent notation for numbers with capital E for SVG parsing
DEVSIX-6645 Autoported commit. Original commit hash: [f3771f179]
1 parent baa4e7d commit 23388ca

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/util/CssDimensionParsingUtilsTest.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,21 +157,29 @@ public virtual void ParseAbsoluteLengthFromNull() {
157157
}
158158

159159
[NUnit.Framework.Test]
160-
public virtual void ParseAboluteLengthExponential01() {
160+
public virtual void ParseAbsoluteLengthExponentialPtTest() {
161161
String value = "1e2pt";
162162
float actual = CssDimensionParsingUtils.ParseAbsoluteLength(value);
163163
float expected = 1e2f;
164164
NUnit.Framework.Assert.AreEqual(expected, actual, 0);
165165
}
166166

167167
[NUnit.Framework.Test]
168-
public virtual void ParseAboluteLengthExponential02() {
168+
public virtual void ParseAbsoluteLengthExponentialPxTest() {
169169
String value = "1e2px";
170170
float actual = CssDimensionParsingUtils.ParseAbsoluteLength(value);
171171
float expected = 1e2f * 0.75f;
172172
NUnit.Framework.Assert.AreEqual(expected, actual, 0);
173173
}
174174

175+
[NUnit.Framework.Test]
176+
public virtual void ParseAbsoluteLengthExponentialCapitalTest() {
177+
String value = "1E-4";
178+
float actual = CssDimensionParsingUtils.ParseAbsoluteLength(value);
179+
float expected = 1e-4f * 0.75f;
180+
NUnit.Framework.Assert.AreEqual(expected, actual, 1e-9);
181+
}
182+
175183
[NUnit.Framework.Test]
176184
public virtual void ParseAbsoluteLength12cmTest() {
177185
// Calculations in CssUtils#parseAbsoluteLength were changed to work

itext/itext.styledxmlparser/itext/styledxmlparser/css/util/CssDimensionParsingUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ private static bool IsDigit(char ch) {
488488
}
489489

490490
private static bool IsExponentNotation(String s, int index) {
491-
return index < s.Length && s[index] == 'e' &&
491+
return index < s.Length && char.ToLower(s[index]) == 'e' &&
492492
// e.g. 12e5
493493
(index + 1 < s.Length && IsDigit(s[index + 1]) ||
494494
// e.g. 12e-5, 12e+5

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
32c1b3194dfe5f5cae361b99d56dc72b5844b25e
1+
f3771f179d110abe0b9ef8e28d6283f93d849268

0 commit comments

Comments
 (0)