コード例 #1
0
ファイル: MarkdownTests.cs プロジェクト: 35e8/roadkill
		public void Internal_Links_Should_Resolve_With_Id()
		{
			// Bug #87

			// Arrange
			Page page = new Page() { Id = 1, Title = "My first page" };

			RepositoryMock repositoryStub = new RepositoryMock();
			repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
			repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

			ApplicationSettings settings = new ApplicationSettings();
			settings.Installed = true;
			settings.UpgradeRequired = false;

			UrlResolverMock resolver = new UrlResolverMock();
			resolver.InternalUrl = "blah";
			MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);
			converter.UrlResolver = resolver;

			string markdownText = "[Link](My-first-page)";
			string invalidMarkdownText = "[Link](My first page)";

			// Act
			string expectedHtml = "<p><a href=\"blah\">Link</a></p>\n";
			string expectedInvalidLinkHtml = "<p>[Link](My first page)</p>\n";

			string actualHtml = converter.ToHtml(markdownText);
			string actualHtmlInvalidLink = converter.ToHtml(invalidMarkdownText);

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
			Assert.That(actualHtmlInvalidLink, Is.EqualTo(expectedInvalidLinkHtml));
		}
コード例 #2
0
ファイル: MarkdownTests.cs プロジェクト: NaseUkolyCZ/roadkill
        public void Code_Blocks_Should_Allow_Quotes()
        {
            // Issue #82
            // Arrange
            Page page = new Page() { Id = 1, Title = "My first page" };

            RepositoryMock repositoryStub = new RepositoryMock();
            repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
            repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

            ApplicationSettings settings = new ApplicationSettings();
            settings.Installed = true;
            settings.UpgradeRequired = false;

            MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);

            string markdownText = "Here is some `// code with a 'quote' in it and another \"quote\"`\n\n" +
                "    var x = \"some tabbed code\";\n\n"; // 2 line breaks followed by 4 spaces (tab stop) at the start indicates a code block

            string expectedHtml = "<p>Here is some <code>// code with a 'quote' in it and another \"quote\"</code></p>\n\n" +
                                "<pre><code>var x = \"some tabbed code\";\n" +
                                "</code></pre>\n";

            // Act
            string actualHtml = converter.ToHtml(markdownText);

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #3
0
        public void Attachment_Link_Should_Not_Have_NoFollow_Attribute()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"&#x2F;Attachments&#x2F;folder&#x2F;myfile&#x2E;jpg\">Some link text</a> <a href=\"&#x2F;Attachments&#x2F;folder2&#x2F;myfile&#x2E;jpg\">Some link text</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[~/folder/myfile.jpg|Some link text]] [[attachment:/folder2/myfile.jpg|Some link text]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
コード例 #4
0
        public void External_Links_With_Anchor_Tag_Should_Retain_The_Anchor()
        {
            // Issue #172
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _repository.AddNewPage(new Page() { Id = 1, Title = "foo" }, "foo", "admin", DateTime.Today);
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;&#x3F;blah&#x3D;xyz&#x23;myanchor\" class=\"external&#x2D;link\">Some link text</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[http://www.google.com/?blah=xyz#myanchor|Some link text]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
コード例 #5
0
        public void Html_Should_Not_Be_Sanitized_If_UseHtmlWhiteList_Setting_Is_False()
        {
            // Arrange
            _applicationSettings.UseHtmlWhiteList = false;
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string htmlFragment = "<div onclick=\"javascript:alert('ouch');\">test</div>";
            MarkupConverter converter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            // Act
            string actualHtml = converter.ToHtml(htmlFragment);

            // Assert
            string expectedHtml = "<p>" + htmlFragment + "\n</p>";
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #6
0
		public void imageparsed_should_convert_to_absolute_path()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Markdown";
			UrlResolverMock resolver = new UrlResolverMock();
			resolver.AbsolutePathSuffix = "123";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			_markupConverter.UrlResolver = resolver;

			// Act
			bool wasCalled = false;
			_markupConverter.Parser.ImageParsed += (object sender, ImageEventArgs e) =>
			{
				wasCalled = (e.Src == "/Attachments/DSC001.jpg123");
			};

			_markupConverter.ToHtml("![Image title](/DSC001.jpg)");

			// Assert
			Assert.True(wasCalled, "ImageParsed.ImageEventArgs.Src did not match.");
		}
コード例 #7
0
		public void specialurl_link_should_not_have_nofollow_attribute()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;Special&#x3A;Random\">Some link text</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[Special:Random|Some link text]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #8
0
		public void internal_wiki_page_link_should_not_have_nofollow_attribute()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_pageRepository.AddNewPage(new Page() { Id = 1, Title = "foo-page" }, "foo", "admin", DateTime.Today);
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;1&#x2F;foo&#x2D;page\">Some link text</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[foo-page|Some link text]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #9
0
		public void links_to_named_anchors_should_not_have_external_css_class()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"&#x23;myanchortag\">hello world</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
		}
コード例 #10
0
        public void Links_With_The_Word_Script_In_Url_Should_Not_Be_Cleaned()
        {
            // Issue #159
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"http&#x3A;&#x2F;&#x2F;msdn&#x2E;microsoft&#x2E;com&#x2F;en&#x2D;us&#x2F;library&#x2F;system&#x2E;componentmodel&#x2E;descriptionattribute&#x2E;aspx\">ComponentModel.Description</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx|ComponentModel.Description]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
コード例 #11
0
		public void links_starting_with_http_www_mailto_tag_are_no_rewritten_as_internal()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;blah&#x2E;com\" class=\"external&#x2D;link\">link1</a> <a rel=\"nofollow\" href=\"www&#x2E;blah&#x2E;com\" class=\"external&#x2D;link\">link2</a> <a rel=\"nofollow\" href=\"mailto&#x3A;spam&#x40;gmail&#x2E;com\" class=\"external&#x2D;link\">spam</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[http://www.blah.com|link1]] [[www.blah.com|link2]] [[mailto:[email protected]|spam]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
		}
コード例 #12
0
		public void links_starting_with_attachmentcolon_should_resolve_as_attachment_paths()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;Attachments&#x2F;my&#x2F;folder&#x2F;image1&#x2E;jpg\">hello world</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[attachment:/my/folder/image1.jpg|hello world]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #13
0
		public void links_with_the_word_script_in_url_should_not_be_cleaned()
		{
			// Issue #159
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;msdn&#x2E;microsoft&#x2E;com&#x2F;en&#x2D;us&#x2F;library&#x2F;system&#x2E;componentmodel&#x2E;descriptionattribute&#x2E;aspx\" class=\"external&#x2D;link\">ComponentModel.Description</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[http://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute.aspx|ComponentModel.Description]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #14
0
        public void Links_With_Dashes_Or_23_Are_Rewritten_And_Not_Parsed_As_Encoded_Hashes()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"&#x23;myanchortag\">hello world</a> <a href=\"https&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;some&#x2D;page&#x2D;23\">google</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]] [[https://www.google.com/some-page-23|google]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #15
0
        public void Links_To_Named_Anchors_Should_Not_Have_External_CSS_Class()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a rel=\"nofollow\" href=\"&#x23;myanchortag\">hello world</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #16
0
        public void Links_Starting_With_Tilde_Should_Resolve_As_Attachment_Paths()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"&#x2F;Attachments&#x2F;my&#x2F;folder&#x2F;image1&#x2E;jpg\">hello world</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[~/my/folder/image1.jpg|hello world]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
コード例 #17
0
        public void Links_Starting_With_Https_Or_Hash_Are_Not_Rewritten_As_Internal()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a rel=\"nofollow\" href=\"&#x23;myanchortag\">hello world</a> <a rel=\"nofollow\" href=\"https&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com\" class=\"external&#x2D;link\">google</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]] [[https://www.google.com|google]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #18
0
        public void Internal_Links_With_Anchor_Tag_Should_Retain_The_Anchor()
        {
            // Issue #172
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _repository.AddNewPage(new Page() { Id = 1, Title = "foo" }, "foo", "admin", DateTime.Today);
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;1&#x2F;foo&#x23;myanchor\">Some link text</a>\n</p>"; // use /index/ as no routing exists

            // Act
            string actualHtml = _markupConverter.ToHtml("[[foo#myanchor|Some link text]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
コード例 #19
0
ファイル: MarkdownTests.cs プロジェクト: NaseUkolyCZ/roadkill
        public void Images_Should_Support_Dimensions_And_Titles()
        {
            // Arrange
            Page page = new Page() { Id = 1, Title = "My first page" };

            RepositoryMock repositoryStub = new RepositoryMock();
            repositoryStub.AddNewPage(page, "My first page", "admin", DateTime.UtcNow);
            repositoryStub.SiteSettings = new SiteSettings() { MarkupType = "Markdown" };

            ApplicationSettings settings = new ApplicationSettings();
            settings.Installed = true;
            settings.UpgradeRequired = false;

            MarkupConverter converter = new MarkupConverter(settings, repositoryStub, _pluginFactory);

            string markdownText = "Here is an image with a title:![Image](/Image1.png \"Image\") \n\n" +
                                  "And another with equal dimensions ![Square](/Image1.png \"Square\" =250x) \n\n" +
                                  "And this one is a rectangle ![Rectangle](/Image1.png \"Rectangle\" =250x350)";

            string expectedHtml = "<p>Here is an image with a title:<img src=\"/Attachments/Image1.png\" border=\"0\" alt=\"Image\" width=\"\" height=\"\" title=\"Image\" /> </p>\n\n" +
                                    "<p>And another with equal dimensions <img src=\"/Attachments/Image1.png\" border=\"0\" alt=\"Square\" width=\"250px\" height=\"\" title=\"Square\" /> </p>\n\n" +
                                    "<p>And this one is a rectangle <img src=\"/Attachments/Image1.png\" border=\"0\" alt=\"Rectangle\" width=\"250px\" height=\"350px\" title=\"Rectangle\" /></p>\n";

            // Act
            string actualHtml = converter.ToHtml(markdownText);

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #20
0
		public void internal_links_with_urlencoded_anchor_tag_should_retain_the_anchor()
		{
			// Issue #172
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_pageRepository.AddNewPage(new Page() { Id = 1, Title = "foo" }, "foo", "admin", DateTime.Today);
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;1&#x2F;foo&#x25;23myanchor\">Some link text</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[foo%23myanchor|Some link text]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #21
0
		public void internal_links_with_anchor_tag_should_retain_the_anchor_with_markdown()
		{
			// Issue #172
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Markdown";
			_pageRepository.AddNewPage(new Page() { Id = 1, Title = "foo" }, "foo", "admin", DateTime.Today);
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;1&#x2F;foo&#x23;myanchor\">Some link text</a></p>\n"; // use /index/ as no routing exists

			// Act
			string actualHtml = _markupConverter.ToHtml("[Some link text](foo#myanchor)");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #22
0
        public void Links_With_Angle_Brackets_And_Quotes_Should_Be_Encoded()
        {
            // Issue #159
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;&#x22;&#x3E;javascript&#x3A;alert&#x28;&#x27;hello&#x27;&#x29;\">ComponentModel</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[http://www.google.com/\">javascript:alert('hello')|ComponentModel]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
        }
コード例 #23
0
		public void links_with_angle_brackets_and_quotes_should_be_encoded()
		{
			// Issue #159
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;&#x22;&#x3E;javascript&#x3A;alert&#x28;&#x27;hello&#x27;&#x29;\" class=\"external&#x2D;link\">ComponentModel</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[http://www.google.com/\">javascript:alert('hello')|ComponentModel]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #24
0
        public void Links_Starting_With_Http_Www_Mailto_Tag_Are_No_Rewritten_As_Internal()
        {
            // Arrange
            _repository.SiteSettings.MarkupType = "Creole";
            _markupConverter = new MarkupConverter(_applicationSettings, _repository, _pluginFactory);

            string expectedHtml = "<p><a href=\"http&#x3A;&#x2F;&#x2F;www&#x2E;blah&#x2E;com\">link1</a> <a href=\"www&#x2E;blah&#x2E;com\">link2</a> <a href=\"mailto&#x3A;spam&#x40;gmail&#x2E;com\">spam</a>\n</p>";

            // Act
            string actualHtml = _markupConverter.ToHtml("[[http://www.blah.com|link1]] [[www.blah.com|link2]] [[mailto:[email protected]|spam]]");

            // Assert
            Assert.That(actualHtml, Is.EqualTo(expectedHtml));
        }
コード例 #25
0
		public void links_starting_with_specialcolon_should_resolve_as_full_specialpage()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a href=\"&#x2F;wiki&#x2F;Special&#x3A;Foo\">My special page</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[Special:Foo|My special page]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml), actualHtml);
		}
コード例 #26
0
		public void links_with_dashes_or_23_are_rewritten_and_not_parsed_as_encoded_hashes()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);

			string expectedHtml = "<p><a rel=\"nofollow\" href=\"&#x23;myanchortag\">hello world</a> <a rel=\"nofollow\" href=\"https&#x3A;&#x2F;&#x2F;www&#x2E;google&#x2E;com&#x2F;some&#x2D;page&#x2D;23\" class=\"external&#x2D;link\">google</a>\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml("[[#myanchortag|hello world]] [[https://www.google.com/some-page-23|google]]");

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
		}
コード例 #27
0
		public void should_not_render_toc_with_multiple_curlies()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			_markupConverter.UrlResolver = new UrlResolverMock();

			string htmlFragment = "Give me a {{TOC}} and a {{{TOC}}} - the should not render a TOC";
			string expected = @"<p>Give me a <div class=""floatnone""><div class=""image&#x5F;frame""><img src=""&#x2F;Attachments&#x2F;TOC""></div></div> and a TOC - the should not render a TOC"
				+ "\n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml(htmlFragment);

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expected));
		}
コード例 #28
0
ファイル: PageViewModel.cs プロジェクト: NaseUkolyCZ/roadkill
        public PageViewModel(PageContent pageContent, MarkupConverter converter)
        {
            if (pageContent == null)
                throw new ArgumentNullException("pageContent");

            if (pageContent.Page == null)
                throw new ArgumentNullException("pageContent.Page");

            if (converter == null)
                throw new ArgumentNullException("converter");

            Id = pageContent.Page.Id;
            Title = pageContent.Page.Title;
            PreviousTitle = pageContent.Page.Title;
            CreatedBy = pageContent.Page.CreatedBy;
            CreatedOn = pageContent.Page.CreatedOn;
            IsLocked = pageContent.Page.IsLocked;
            ModifiedBy = pageContent.Page.ModifiedBy;
            ModifiedOn = pageContent.Page.ModifiedOn;
            RawTags = pageContent.Page.Tags;
            Content = pageContent.Text;
            VersionNumber = pageContent.VersionNumber;

            PageHtml pageHtml = converter.ToHtml(pageContent.Text);
            ContentAsHtml = pageHtml.Html;
            IsCacheable = pageHtml.IsCacheable;
            PluginHeadHtml = pageHtml.HeadHtml;
            PluginFooterHtml = pageHtml.FooterHtml;
            PluginPreContainer = pageHtml.PreContainerHtml;
            PluginPostContainer = pageHtml.PostContainerHtml;

            CreatedOn = DateTime.SpecifyKind(CreatedOn, DateTimeKind.Utc);
            ModifiedOn = DateTime.SpecifyKind(ModifiedOn, DateTimeKind.Utc);
            AllTags = new List<TagViewModel>();
        }
コード例 #29
0
		public void ImageParsed_Should_Not_Rewrite_Images_As_Internal_That_Start_With_Known_Prefixes(string imageUrl)
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Markdown";
			UrlResolverMock resolver = new UrlResolverMock();
			resolver.AbsolutePathSuffix = "123";

			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			_markupConverter.UrlResolver = resolver;

			bool wasCalled = false;
			_markupConverter.Parser.ImageParsed += (object sender, ImageEventArgs e) =>
			{
				wasCalled = (e.Src == imageUrl);
			};

			// Act
			_markupConverter.ToHtml("![Image title](" + imageUrl + ")");

			// Assert
			Assert.True(wasCalled);
		}
コード例 #30
0
		public void should_remove_script_link_iframe_frameset_frame_applet_tags_from_text()
		{
			// Arrange
			_settingsRepository.SiteSettings.MarkupType = "Creole";
			_markupConverter = new MarkupConverter(_applicationSettings, _settingsRepository, _pageRepository, _pluginFactory);
			string markdown = " some text <script type=\"text/html\">while(true)alert('lolz');</script>" +
				"<iframe src=\"google.com\"></iframe><frame>blah</frame> <applet code=\"MyApplet.class\" width=100 height=140></applet>" +
				"<frameset src='new.html'></frameset>";

			string expectedHtml = "<p> some text blah \n</p>";

			// Act
			string actualHtml = _markupConverter.ToHtml(markdown);

			// Assert
			Assert.That(actualHtml, Is.EqualTo(expectedHtml));
		}