diff --git a/itext.tests/itext.io.tests/itext/io/util/ZlibUtilTest.cs b/itext.tests/itext.io.tests/itext/io/util/ZlibUtilTest.cs new file mode 100644 index 0000000000..d18f046eb9 --- /dev/null +++ b/itext.tests/itext.io.tests/itext/io/util/ZlibUtilTest.cs @@ -0,0 +1,75 @@ +/* +This file is part of the iText (R) project. +Copyright (c) 1998-2024 Apryse Group NV +Authors: Apryse Software. + +This program is offered under a commercial and under the AGPL license. +For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below. + +AGPL licensing: +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Affero General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Affero General Public License for more details. + +You should have received a copy of the GNU Affero General Public License +along with this program. If not, see . +*/ +using System; +using System.IO; +using iText.Commons.Utils; +using iText.IO.Source; +using iText.Test; + +namespace iText.IO.Util { + [NUnit.Framework.Category("IntegrationTest")] + public class ZlibUtilTest : ExtendedITextTest { + private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext + .CurrentContext.TestDirectory) + "/resources/itext/io/util/"; + + private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory + + "/test/itext/io/util/"; + + [NUnit.Framework.SetUp] + public virtual void SetUp() { + CreateOrClearDestinationFolder(DESTINATION_FOLDER); + } + + [NUnit.Framework.Test] + public virtual void ArrayIndexOutOfBoundsDeflateTest() { + // Test file is taken from https://issues.jenkins.io/browse/JENKINS-19473 + // Unzip test file first + using (ZipFileReader reader = new ZipFileReader(SOURCE_FOLDER + "jzlib.zip")) { + using (Stream @is = reader.ReadFromZip("jzlib.fail")) { + using (Stream os = FileUtil.GetFileOutputStream(DESTINATION_FOLDER + "jzlib.fail")) { + byte[] buf = new byte[8192]; + int length; + while ((length = @is.Read(buf)) != -1) { + os.Write(buf, 0, length); + } + } + } + } + // Deflate it + using (Stream is_1 = FileUtil.GetInputStreamForFile(DESTINATION_FOLDER + "jzlib.fail")) { + using (Stream os_1 = FileUtil.GetFileOutputStream(DESTINATION_FOLDER + "jzlib.fail.zz")) { + // -1 stands for default compression + using (DeflaterOutputStream zip = new DeflaterOutputStream(os_1, -1)) { + byte[] buf = new byte[8192]; + int length; + while ((length = is_1.Read(buf)) != -1) { + zip.Write(buf, 0, length); + } + } + } + } + NUnit.Framework.Assert.IsTrue(FileUtil.FileExists(DESTINATION_FOLDER + "jzlib.fail.zz")); + NUnit.Framework.Assert.IsTrue(FileUtil.IsFileNotEmpty(DESTINATION_FOLDER + "jzlib.fail.zz")); + } + } +} diff --git a/itext.tests/itext.io.tests/resources/itext/io/util/jzlib.zip b/itext.tests/itext.io.tests/resources/itext/io/util/jzlib.zip new file mode 100644 index 0000000000..e8db010ee5 Binary files /dev/null and b/itext.tests/itext.io.tests/resources/itext/io/util/jzlib.zip differ diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2AnnotationCheckTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2AnnotationCheckTest.cs index 5e43ea0640..606893f93b 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2AnnotationCheckTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2AnnotationCheckTest.cs @@ -38,6 +38,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA2AnnotationCheckTest : ExtendedITextTest { public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2LayoutOcgTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2LayoutOcgTest.cs index 91331bc727..39cd27cbae 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2LayoutOcgTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2LayoutOcgTest.cs @@ -34,6 +34,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA2LayoutOcgTest : ExtendedITextTest { public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2OCPropertiesTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2OCPropertiesTest.cs index 6001ed7523..8699b9e6fa 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2OCPropertiesTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA2OCPropertiesTest.cs @@ -30,6 +30,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA2OCPropertiesTest : ExtendedITextTest { public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA3CatalogCheckTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA3CatalogCheckTest.cs index fbaf22c68e..a197eca791 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA3CatalogCheckTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA3CatalogCheckTest.cs @@ -29,6 +29,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA3CatalogCheckTest : ExtendedITextTest { public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4AnnotationCheckTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4AnnotationCheckTest.cs index 48b23a7f43..c50a00c68e 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4AnnotationCheckTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4AnnotationCheckTest.cs @@ -34,6 +34,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA4AnnotationCheckTest : ExtendedITextTest { private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4CatalogCheckTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4CatalogCheckTest.cs index 8ba46df7a8..3ac4cabcc5 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4CatalogCheckTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4CatalogCheckTest.cs @@ -36,6 +36,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA4CatalogCheckTest : ExtendedITextTest { public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4GraphicsCheckTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4GraphicsCheckTest.cs index 3930c0d541..357bee7000 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4GraphicsCheckTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4GraphicsCheckTest.cs @@ -40,6 +40,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA4GraphicsCheckTest : ExtendedITextTest { public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4TransparencyCheckTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4TransparencyCheckTest.cs index e3aa1ce166..7f31be211b 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4TransparencyCheckTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfA4TransparencyCheckTest.cs @@ -39,6 +39,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfA4TransparencyCheckTest : ExtendedITextTest { public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFontTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFontTest.cs index bf1ad71315..014746294e 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFontTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFontTest.cs @@ -37,6 +37,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfAFontTest : ExtendedITextTest { //\cond DO_NOT_DOCUMENT diff --git a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFormFieldTest.cs b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFormFieldTest.cs index 297b045dc5..81eefa979b 100644 --- a/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFormFieldTest.cs +++ b/itext.tests/itext.pdfa.tests/itext/pdfa/PdfAFormFieldTest.cs @@ -47,6 +47,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfa { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfAFormFieldTest : ExtendedITextTest { public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.pdfua.tests/itext/pdfua/PdfUAAnnotationsTest.cs b/itext.tests/itext.pdfua.tests/itext/pdfua/PdfUAAnnotationsTest.cs index 11a635f21b..fca0c37e40 100644 --- a/itext.tests/itext.pdfua.tests/itext/pdfua/PdfUAAnnotationsTest.cs +++ b/itext.tests/itext.pdfua.tests/itext/pdfua/PdfUAAnnotationsTest.cs @@ -46,6 +46,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfua { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfUAAnnotationsTest : ExtendedITextTest { private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext @@ -760,6 +761,7 @@ public virtual void Ua1PrinterMAnnotNotInTagStructureTest() { NUnit.Framework.Assert.IsNotNull(new VeraPdfValidator().Validate(outPdf)); } + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) private PdfTextAnnotation CreateRichTextAnnotation() { PdfTextAnnotation annot = new PdfTextAnnotation(new Rectangle(100, 100, 100, 100)); annot.SetContents("Rich media annot"); diff --git a/itext.tests/itext.pdfua.tests/itext/pdfua/UaValidationTestFramework.cs b/itext.tests/itext.pdfua.tests/itext/pdfua/UaValidationTestFramework.cs index b28e73e7bb..45a5083800 100644 --- a/itext.tests/itext.pdfua.tests/itext/pdfua/UaValidationTestFramework.cs +++ b/itext.tests/itext.pdfua.tests/itext/pdfua/UaValidationTestFramework.cs @@ -33,6 +33,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfua { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) /// Class that helps to test PDF/UA conformance. /// /// Class that helps to test PDF/UA conformance. diff --git a/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAHeadingsTest.cs b/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAHeadingsTest.cs index 67b8f75269..4f89f630d1 100644 --- a/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAHeadingsTest.cs +++ b/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAHeadingsTest.cs @@ -39,6 +39,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Pdfua.Checkers { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfUAHeadingsTest : ExtendedITextTest { private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory diff --git a/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAXfaTest.cs b/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAXfaTest.cs index fa1a739f40..9ad9aa07a3 100644 --- a/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAXfaTest.cs +++ b/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUAXfaTest.cs @@ -29,6 +29,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Utils; namespace iText.Pdfua.Checkers { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) [NUnit.Framework.Category("IntegrationTest")] public class PdfUAXfaTest : ExtendedITextTest { private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory diff --git a/itext.tests/itext.sign.tests/itext/signatures/sign/PdfASigningTest.cs b/itext.tests/itext.sign.tests/itext/signatures/sign/PdfASigningTest.cs index 71b2976f83..1e18aa3ada 100644 --- a/itext.tests/itext.sign.tests/itext/signatures/sign/PdfASigningTest.cs +++ b/itext.tests/itext.sign.tests/itext/signatures/sign/PdfASigningTest.cs @@ -37,6 +37,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Signatures.Sign { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android) [NUnit.Framework.Category("BouncyCastleIntegrationTest")] public class PdfASigningTest : ExtendedITextTest { public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext diff --git a/itext.tests/itext.sign.tests/itext/signatures/sign/SignedAppearanceTextTest.cs b/itext.tests/itext.sign.tests/itext/signatures/sign/SignedAppearanceTextTest.cs index c92cb347d7..751df93fcf 100644 --- a/itext.tests/itext.sign.tests/itext/signatures/sign/SignedAppearanceTextTest.cs +++ b/itext.tests/itext.sign.tests/itext/signatures/sign/SignedAppearanceTextTest.cs @@ -48,6 +48,7 @@ You should have received a copy of the GNU Affero General Public License using iText.Test.Pdfa; namespace iText.Signatures.Sign { + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) [NUnit.Framework.Category("BouncyCastleIntegrationTest")] public class SignedAppearanceTextTest : ExtendedITextTest { private static readonly IBouncyCastleFactory FACTORY = BouncyCastleFactoryCreator.GetFactory(); diff --git a/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.cs b/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.cs index 6f8683515b..8fc13c8a48 100644 --- a/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.cs +++ b/itext.tests/itext.styledxmlparser.tests/itext/styledxmlparser/css/resolve/CssDeclarationValueTokenizerTest.cs @@ -67,6 +67,38 @@ public virtual void FunctionTest06() { )); } + [NUnit.Framework.Test] + public virtual void StringTest01() { + RunTest("'a b c'", JavaUtil.ArraysAsList("a b c"), JavaUtil.ArraysAsList(CssDeclarationValueTokenizer.TokenType + .STRING)); + } + + [NUnit.Framework.Test] + public virtual void StringTest02() { + RunTest("\"a b c\"", JavaUtil.ArraysAsList("a b c"), JavaUtil.ArraysAsList(CssDeclarationValueTokenizer.TokenType + .STRING)); + } + + [NUnit.Framework.Test] + public virtual void StringTest03() { + RunTest("[ aa bb cc ]", JavaUtil.ArraysAsList("[ aa bb cc ]"), JavaUtil.ArraysAsList(CssDeclarationValueTokenizer.TokenType + .STRING)); + } + + [NUnit.Framework.Test] + public virtual void StringTest04() { + RunTest("[aa bb cc] [dd ee] 'ff ff'", JavaUtil.ArraysAsList("[aa bb cc]", "[dd ee]", "ff ff"), JavaUtil.ArraysAsList + (CssDeclarationValueTokenizer.TokenType.STRING, CssDeclarationValueTokenizer.TokenType.STRING, CssDeclarationValueTokenizer.TokenType + .STRING)); + } + + [NUnit.Framework.Test] + public virtual void FunctionWithSquareBracketsTest04() { + RunTest("'prefix' repeat(3, [aa bb cc] 2 [dd ee] 3) 'ff ff'", JavaUtil.ArraysAsList("prefix", "repeat(3, [aa bb cc] 2 [dd ee] 3)" + , "ff ff"), JavaUtil.ArraysAsList(CssDeclarationValueTokenizer.TokenType.STRING, CssDeclarationValueTokenizer.TokenType + .FUNCTION, CssDeclarationValueTokenizer.TokenType.STRING)); + } + private void RunTest(String src, IList tokenValues, IList tokenTypes) { CssDeclarationValueTokenizer tokenizer = new CssDeclarationValueTokenizer(src); diff --git a/itext/itext.io/itext/io/util/zlib/Deflate.cs b/itext/itext.io/itext/io/util/zlib/Deflate.cs index af15f4a513..bd64e10e92 100644 --- a/itext/itext.io/itext/io/util/zlib/Deflate.cs +++ b/itext/itext.io/itext/io/util/zlib/Deflate.cs @@ -1383,7 +1383,7 @@ internal int deflateInit2(ZStream strm, int level, int method, int windowBits, pending_buf = new byte[lit_bufsize*4]; pending_buf_size = lit_bufsize*4; - d_buf = lit_bufsize/2; + d_buf = lit_bufsize; l_buf = (1+2)*lit_bufsize; this.level = level; diff --git a/itext/itext.styledxmlparser/itext/styledxmlparser/css/parse/CssDeclarationValueTokenizer.cs b/itext/itext.styledxmlparser/itext/styledxmlparser/css/parse/CssDeclarationValueTokenizer.cs index 4ee7000093..ccd20c2295 100644 --- a/itext/itext.styledxmlparser/itext/styledxmlparser/css/parse/CssDeclarationValueTokenizer.cs +++ b/itext/itext.styledxmlparser/itext/styledxmlparser/css/parse/CssDeclarationValueTokenizer.cs @@ -163,26 +163,43 @@ private CssDeclarationValueTokenizer.Token GetNextToken() { ); } else { - if (curChar == ',' && !inString && functionDepth == 0) { - if (buff.Length == 0) { - return new CssDeclarationValueTokenizer.Token(",", CssDeclarationValueTokenizer.TokenType.COMMA); - } - else { - --index; - return new CssDeclarationValueTokenizer.Token(buff.ToString(), CssDeclarationValueTokenizer.TokenType.UNKNOWN - ); - } + if (curChar == '[') { + stringQuote = (char)0; + inString = true; + buff.Append(curChar); } else { - if (iText.IO.Util.TextUtil.IsWhiteSpace(curChar)) { - if (functionDepth > 0) { - buff.Append(curChar); - } - return new CssDeclarationValueTokenizer.Token(buff.ToString(), functionDepth > 0 ? CssDeclarationValueTokenizer.TokenType - .FUNCTION : CssDeclarationValueTokenizer.TokenType.UNKNOWN); + if (curChar == ']') { + inString = false; + buff.Append(curChar); + return new CssDeclarationValueTokenizer.Token(buff.ToString(), CssDeclarationValueTokenizer.TokenType.STRING + ); } else { - buff.Append(curChar); + if (curChar == ',' && !inString && functionDepth == 0) { + if (buff.Length == 0) { + return new CssDeclarationValueTokenizer.Token(",", CssDeclarationValueTokenizer.TokenType.COMMA); + } + else { + --index; + return new CssDeclarationValueTokenizer.Token(buff.ToString(), CssDeclarationValueTokenizer.TokenType.UNKNOWN + ); + } + } + else { + if (iText.IO.Util.TextUtil.IsWhiteSpace(curChar)) { + if (functionDepth > 0 || inString) { + buff.Append(curChar); + } + if (!inString) { + return new CssDeclarationValueTokenizer.Token(buff.ToString(), functionDepth > 0 ? CssDeclarationValueTokenizer.TokenType + .FUNCTION : CssDeclarationValueTokenizer.TokenType.UNKNOWN); + } + } + else { + buff.Append(curChar); + } + } } } } @@ -206,9 +223,13 @@ private bool IsHexDigit(char c) { /// the function buffer private void ProcessFunctionToken(CssDeclarationValueTokenizer.Token token, StringBuilder functionBuffer) { if (token.IsString()) { - functionBuffer.Append(stringQuote); + if (stringQuote != 0) { + functionBuffer.Append(stringQuote); + } functionBuffer.Append(token.GetValue()); - functionBuffer.Append(stringQuote); + if (stringQuote != 0) { + functionBuffer.Append(stringQuote); + } } else { functionBuffer.Append(token.GetValue()); diff --git a/port-hash b/port-hash index 535623cd15..d167ab831d 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -9efb1ea892c9de623115126013ec4bdb361c4695 +fc414da4ec172670063a0b874ecf6af0b7629338