Sanitize() public static method

public static Sanitize ( String str ) : String
str String
return String
Beispiel #1
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag,
         * java.util.List, com.itextpdf.text.Document, java.lang.String)
         */
        public override IList <IElement> Content(IWorkerContext ctx, Tag tag, String content)
        {
            List <Chunk>    sanitizedChunks = HTMLUtils.Sanitize(content, false);
            List <IElement> l = new List <IElement>(1);

            foreach (Chunk sanitized in sanitizedChunks)
            {
                HtmlPipelineContext myctx;
                try {
                    myctx = GetHtmlPipelineContext(ctx);
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(e);
                }
                if (tag.CSS.ContainsKey(CSS.Property.TAB_INTERVAL))
                {
                    TabbedChunk tabbedChunk = new TabbedChunk(sanitized.Content);
                    if (null != GetLastChild(tag) && GetLastChild(tag).CSS.ContainsKey(CSS.Property.XFA_TAB_COUNT))
                    {
                        tabbedChunk.TabCount = int.Parse(GetLastChild(tag).CSS[CSS.Property.XFA_TAB_COUNT]);
                    }
                    l.Add(GetCssAppliers().Apply(tabbedChunk, tag, myctx));
                }
                else if (null != GetLastChild(tag) && GetLastChild(tag).CSS.ContainsKey(CSS.Property.XFA_TAB_COUNT))
                {
                    TabbedChunk tabbedChunk = new TabbedChunk(sanitized.Content);
                    tabbedChunk.TabCount = int.Parse(GetLastChild(tag).CSS[CSS.Property.XFA_TAB_COUNT]);
                    l.Add(GetCssAppliers().Apply(tabbedChunk, tag, myctx));
                }
                else
                {
                    l.Add(GetCssAppliers().Apply(sanitized, tag, myctx));
                }
            }
            return(l);
        }
Beispiel #2
0
        /*
         * (non-Javadoc)
         *
         * @see
         * com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag,
         * java.util.List, com.itextpdf.text.Document, java.lang.String)
         */
        public override IList <IElement> Content(IWorkerContext ctx, Tag tag, String content)
        {
            String           sanitized = HTMLUtils.Sanitize(content);
            IList <IElement> l         = new List <IElement>(1);

            if (sanitized.Length > 0)
            {
                if (tag.CSS.ContainsKey(CSS.Property.TAB_INTERVAL))
                {
                    TabbedChunk tabbedChunk = new TabbedChunk(sanitized);
                    if (null != GetLastChild(tag) && GetLastChild(tag).CSS.ContainsKey(CSS.Property.XFA_TAB_COUNT))
                    {
                        tabbedChunk.TabCount = int.Parse(GetLastChild(tag).CSS[CSS.Property.XFA_TAB_COUNT]);
                    }
                    l.Add(new ChunkCssApplier().Apply(tabbedChunk, tag));
                }
                else if (null != GetLastChild(tag) && GetLastChild(tag).CSS.ContainsKey(CSS.Property.XFA_TAB_COUNT))
                {
                    TabbedChunk tabbedChunk = new TabbedChunk(sanitized);
                    tabbedChunk.TabCount = int.Parse(GetLastChild(tag).CSS[CSS.Property.XFA_TAB_COUNT]);
                    l.Add(new ChunkCssApplier().Apply(tabbedChunk, tag));
                }
                else
                {
                    l.Add(new ChunkCssApplier().Apply(new Chunk(sanitized), tag));
                }
            }
            return(l);
        }
Beispiel #3
0
        protected virtual List <IElement> TextContent(IWorkerContext ctx, Tag tag, String content)
        {
            List <Chunk>    sanitizedChunks = HTMLUtils.Sanitize(content, false);
            List <IElement> l = new List <IElement>(1);

            foreach (Chunk sanitized in sanitizedChunks)
            {
                try {
                    l.Add(GetCssAppliers().Apply(sanitized, tag, GetHtmlPipelineContext(ctx)));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(e);
                }
            }
            return(l);
        }
Beispiel #4
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag, java.util.List,
         * com.itextpdf.text.Document, java.lang.String)
         */
        public override IList <IElement> Content(IWorkerContext ctx, Tag tag, String content)
        {
            String           sanitized = HTMLUtils.Sanitize(content);
            IList <IElement> l         = new List <IElement>(1);

            if (sanitized.Length > 0)
            {
                try {
                    l.Add(GetCssAppliers().Apply(new NoNewLineParagraph(sanitized), tag, GetHtmlPipelineContext(ctx)));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
                }
            }
            return(l);
        }
Beispiel #5
0
        /*
         * (non-Javadoc)
         *
         * @see com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag, java.util.List,
         * com.itextpdf.text.Document, java.lang.String)
         */
        public override IList <IElement> Content(IWorkerContext ctx, Tag tag, String content)
        {
            List <Chunk>       sanitizedChunks = HTMLUtils.Sanitize(content, false);
            List <IElement>    l = new List <IElement>(1);
            NoNewLineParagraph sanitizedNoNewLineParagraph = new NoNewLineParagraph();

            foreach (Chunk sanitized in sanitizedChunks)
            {
                Chunk c = GetCssAppliers().ChunkCssAplier.Apply(sanitized, tag);
                sanitizedNoNewLineParagraph.Add(c);
            }
            if (sanitizedNoNewLineParagraph.Count > 0)
            {
                try {
                    l.Add(GetCssAppliers().Apply(sanitizedNoNewLineParagraph, tag, GetHtmlPipelineContext(ctx)));
                } catch (NoCustomContextException e) {
                    throw new RuntimeWorkerException(LocaleMessages.GetInstance().GetMessage(LocaleMessages.NO_CUSTOM_CONTEXT), e);
                }
            }
            return(l);
        }
Beispiel #6
0
        /* (non-Javadoc)
         * @see com.itextpdf.tool.xml.ITagProcessor#content(com.itextpdf.tool.xml.Tag, java.lang.String)
         */
        public override IList <IElement> Content(IWorkerContext ctx, Tag tag, String content)
        {
            List <Chunk>       sanitizedChunks = HTMLUtils.Sanitize(content, false);
            List <IElement>    l = new List <IElement>(1);
            NoNewLineParagraph sanitizedNoNewLineParagraph = new NoNewLineParagraph();

            try {
                HtmlPipelineContext htmlPipelineContext = GetHtmlPipelineContext(ctx);
                foreach (Chunk sanitized in sanitizedChunks)
                {
                    sanitizedNoNewLineParagraph.Add(GetCssAppliers().Apply(sanitized, tag, htmlPipelineContext));
                }
                if (sanitizedNoNewLineParagraph.Count > 0)
                {
                    l.Add(GetCssAppliers().Apply(sanitizedNoNewLineParagraph, tag, htmlPipelineContext));
                }
            }
            catch (NoCustomContextException e) {
                throw new RuntimeWorkerException(e);
            }
            return(l);
        }