Esempio n. 1
0
        protected override void Dispose(bool disposing)
        {
            if (fragmentToHtmlConverter != null)
            {
                ((IDisposable)fragmentToHtmlConverter).Dispose();
                fragmentToHtmlConverter = null;
            }

            if (fragmentToTextConverter != null)
            {
                ((IDisposable)fragmentToTextConverter).Dispose();
                fragmentToTextConverter = null;
            }
#if false
            if (this.fragmentToRtfConverter != null)
            {
                ((IDisposable)this.fragmentToRtfConverter).Dispose();
                this.fragmentToRtfConverter = null;
            }
#endif
            if (fragmentParser != null)
            {
                ((IDisposable)fragmentParser).Dispose();
                fragmentParser = null;
            }

            Reset();
            base.Dispose(disposing);
        }
Esempio n. 2
0
        private IProducerConsumer CreateChain(ConverterInput input, ConverterOutput output, IProgressMonitor progressMonitor)
        {
            this.locked = true;
            HtmlInjection     htmlInjection  = null;
            HtmlInjection     htmlInjection2 = null;
            IProducerConsumer result;

            try
            {
                if (this.injectHead != null || this.injectTail != null)
                {
                    htmlInjection2          = new HtmlInjection(this.injectHead, this.injectTail, this.injectionFormat, this.filterHtml, this.htmlCallback, this.testBoundaryConditions, null, progressMonitor);
                    htmlInjection           = htmlInjection2;
                    this.normalizeInputHtml = true;
                }
                if (this.filterHtml || this.outputFragment || this.htmlCallback != null)
                {
                    this.normalizeInputHtml = true;
                }
                IHtmlParser parser2;
                if (this.normalizeInputHtml)
                {
                    HtmlParser parser = new HtmlParser(input, this.detectEncodingFromMetaTag, false, this.testMaxTokenRuns, this.testMaxHtmlTagAttributes, this.testBoundaryConditions);
                    parser2        = new HtmlNormalizingParser(parser, htmlInjection, this.htmlCallback != null, this.testMaxHtmlNormalizerNesting, this.testBoundaryConditions, this.testNormalizerTraceStream, this.testNormalizerTraceShowTokenNum, this.testNormalizerTraceStopOnTokenNum);
                    htmlInjection2 = null;
                }
                else
                {
                    parser2 = new HtmlParser(input, this.detectEncodingFromMetaTag, false, this.testMaxTokenRuns, this.testMaxHtmlTagAttributes, this.testBoundaryConditions);
                }
                HtmlWriter writer = new HtmlWriter(output, this.filterHtml, this.normalizeInputHtml && !this.testNoNewLines);
                result = new HtmlToHtmlConverter(parser2, writer, this.testConvertFragment, this.outputFragment, this.filterHtml, this.htmlCallback, this.testTruncateForCallback, htmlInjection != null && htmlInjection.HaveTail, this.testTraceStream, this.testTraceShowTokenNum, this.testTraceStopOnTokenNum, this.smallCssBlockThreshold, this.preserveDisplayNoneStyle, progressMonitor);
            }
            finally
            {
                IDisposable disposable = htmlInjection2;
                if (disposable != null)
                {
                    disposable.Dispose();
                    htmlInjection2 = null;
                }
            }
            return(result);
        }
Esempio n. 3
0
        private void CreateHtmlToHtmlConverter(string fragment, HtmlWriter writer)
        {
            var parser = new HtmlParser(
                new ConverterBufferInput(fragment, progressMonitor),
                false,
                (injectionFormat == HeaderFooterFormat.Text),
                64,
                8,
                testBoundaryConditions);

            IHtmlParser parserInterface = parser;


            if (injectionFormat == HeaderFooterFormat.Html)
            {
                parserInterface = new HtmlNormalizingParser(
                    parser,
                    null,
                    false,
                    HtmlSupport.HtmlNestingLimit,
                    testBoundaryConditions,
                    null,
                    true,
                    0);
            }

            fragmentToHtmlConverter = new HtmlToHtmlConverter(
                parserInterface,
                writer,
                true,
                injectionFormat == HeaderFooterFormat.Html,
                filterHtml,
                callback,
                true,
                false,
                traceStream,
                true,
                0,
                -1,
                false,
                progressMonitor);
        }
 protected override void Dispose(bool disposing)
 {
     if (fragmentToHtmlConverter != null)
     {
         ((IDisposable)fragmentToHtmlConverter).Dispose();
         fragmentToHtmlConverter = null;
     }
     if (fragmentToTextConverter != null)
     {
         ((IDisposable)fragmentToTextConverter).Dispose();
         fragmentToTextConverter = null;
     }
     if (fragmentParser != null)
     {
         ((IDisposable)fragmentParser).Dispose();
         fragmentParser = null;
     }
     base.Reset();
     base.Dispose(disposing);
 }
        // Token: 0x06000EFA RID: 3834 RVA: 0x00073B80 File Offset: 0x00071D80
        internal IProducerConsumer CreateChain(RtfEncapsulation encapsulation, RtfParser parser, ConverterOutput output, IProgressMonitor progressMonitor)
        {
            this.rtfEncapsulation = encapsulation;
            if (this.reportBytes == null)
            {
                throw new InvalidOperationException("I have an RtfParser but no ReportBytes.");
            }
            output.ReportBytes = this.reportBytes;
            IProducerConsumer result;

            if (encapsulation != RtfEncapsulation.Html)
            {
                HtmlInjection injection = null;
                if (this.injectHead != null || this.injectTail != null)
                {
                    injection = new HtmlInjection(this.injectHead, this.injectTail, this.injectionFormat, this.filterHtml, this.htmlCallback, this.testBoundaryConditions, null, progressMonitor);
                }
                HtmlWriter         writer             = new HtmlWriter(output, this.filterHtml, !this.testNoNewLines);
                FormatOutput       output2            = new HtmlFormatOutput(writer, injection, this.outputFragment, this.testFormatTraceStream, this.testFormatOutputTraceStream, this.filterHtml, this.htmlCallback, true);
                RtfFormatConverter rtfFormatConverter = new RtfFormatConverter(parser, output2, null, false, this.testTraceStream, this.testTraceShowTokenNum, this.testTraceStopOnTokenNum, this.testFormatConverterTraceStream);
                result = rtfFormatConverter;
            }
            else
            {
                HtmlInjection htmlInjection  = null;
                HtmlInjection htmlInjection2 = null;
                try
                {
                    if (this.injectHead != null || this.injectTail != null)
                    {
                        htmlInjection2          = new HtmlInjection(this.injectHead, this.injectTail, this.injectionFormat, this.filterHtml, this.htmlCallback, this.testBoundaryConditions, null, progressMonitor);
                        htmlInjection           = htmlInjection2;
                        this.normalizeInputHtml = true;
                    }
                    if (this.filterHtml || this.outputFragment || this.htmlCallback != null)
                    {
                        this.normalizeInputHtml = true;
                    }
                    HtmlInRtfExtractingInput input = new HtmlInRtfExtractingInput(parser, this.maxHtmlTagSize, this.testBoundaryConditions, this.testTraceStream, this.testTraceShowTokenNum, this.testTraceStopOnTokenNum);
                    IHtmlParser parser3;
                    if (this.normalizeInputHtml)
                    {
                        HtmlParser parser2 = new HtmlParser(input, false, false, this.testMaxTokenRuns, this.testMaxHtmlTagAttributes, this.testBoundaryConditions);
                        parser3        = new HtmlNormalizingParser(parser2, htmlInjection, this.htmlCallback != null, this.testMaxHtmlNormalizerNesting, this.testBoundaryConditions, this.testNormalizerTraceStream, this.testNormalizerTraceShowTokenNum, this.testNormalizerTraceStopOnTokenNum);
                        htmlInjection2 = null;
                    }
                    else
                    {
                        parser3 = new HtmlParser(input, false, false, this.testMaxTokenRuns, this.testMaxHtmlTagAttributes, this.testBoundaryConditions);
                    }
                    HtmlWriter writer2 = new HtmlWriter(output, this.filterHtml, this.normalizeInputHtml && !this.testNoNewLines);
                    result = new HtmlToHtmlConverter(parser3, writer2, false, this.outputFragment, this.filterHtml, this.htmlCallback, this.testTruncateForCallback, htmlInjection != null && htmlInjection.HaveTail, this.testHtmlTraceStream, this.testHtmlTraceShowTokenNum, this.testHtmlTraceStopOnTokenNum, this.smallCssBlockThreshold, this.preserveDisplayNoneStyle, progressMonitor);
                }
                finally
                {
                    IDisposable disposable = htmlInjection2;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                        htmlInjection2 = null;
                    }
                }
            }
            return(result);
        }
Esempio n. 6
0
 public static bool IsUrlSchemaSafe(string schema)
 {
     return(HtmlToHtmlConverter.TestSafeUrlSchema(schema));
 }
Esempio n. 7
0
 public HtmlToHtmlTagContext(HtmlToHtmlConverter converter)
 {
     this.converter = converter;
 }
Esempio n. 8
0
        public void Inject(bool head, HtmlWriter writer)
        {
            if (head)
            {
                if (injectHead != null && !headInjected)
                {
                    if (injectionFormat == HeaderFooterFormat.Text)
                    {
                        writer.WriteStartTag(HtmlNameIndex.TT);
                        writer.WriteStartTag(HtmlNameIndex.Pre);
                        writer.WriteNewLine();
                    }

                    CreateHtmlToHtmlConverter(injectHead, writer);

                    while (!fragmentToHtmlConverter.Flush())
                    {
                    }

                    headInjected = true;


                    if (injectTail == null)
                    {
                        ((IDisposable)fragmentToHtmlConverter).Dispose();
                        fragmentToHtmlConverter = null;
                    }

                    if (injectionFormat == HeaderFooterFormat.Text)
                    {
                        writer.WriteEndTag(HtmlNameIndex.Pre);
                        writer.WriteEndTag(HtmlNameIndex.TT);
                    }
                }
            }
            else
            {
                if (injectHead != null && !headInjected)
                {
                    InternalDebug.Assert(false);


                    headInjected = true;
                }

                if (injectTail != null && !tailInjected)
                {
                    if (injectionFormat == HeaderFooterFormat.Text)
                    {
                        writer.WriteStartTag(HtmlNameIndex.TT);
                        writer.WriteStartTag(HtmlNameIndex.Pre);
                        writer.WriteNewLine();
                    }

                    if (fragmentToHtmlConverter == null)
                    {
                        CreateHtmlToHtmlConverter(injectTail, writer);
                    }
                    else
                    {
                        fragmentToHtmlConverter.Initialize(
                            injectTail,
                            (injectionFormat == HeaderFooterFormat.Text));
                    }

                    while (!fragmentToHtmlConverter.Flush())
                    {
                    }


                    ((IDisposable)fragmentToHtmlConverter).Dispose();
                    fragmentToHtmlConverter = null;

                    tailInjected = true;

                    if (injectionFormat == HeaderFooterFormat.Text)
                    {
                        writer.WriteEndTag(HtmlNameIndex.Pre);
                        writer.WriteEndTag(HtmlNameIndex.TT);
                    }
                }
            }
        }