completes: U4-5148 Remove TidyNet from the core and anything that references/uses it
This commit is contained in:
@@ -31,7 +31,6 @@ if ($project) {
|
||||
if(Test-Path $umbracoBinFolder\SQLCE4Umbraco.dll) { Remove-Item $umbracoBinFolder\SQLCE4Umbraco.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\System.Data.SqlServerCe.dll) { Remove-Item $umbracoBinFolder\System.Data.SqlServerCe.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\System.Data.SqlServerCe.Entity.dll) { Remove-Item $umbracoBinFolder\System.Data.SqlServerCe.Entity.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\TidyNet.dll) { Remove-Item $umbracoBinFolder\TidyNet.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.dll) { Remove-Item $umbracoBinFolder\umbraco.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\Umbraco.Core.dll) { Remove-Item $umbracoBinFolder\Umbraco.Core.dll -Force -Confirm:$false }
|
||||
if(Test-Path $umbracoBinFolder\umbraco.DataLayer.dll) { Remove-Item $umbracoBinFolder\umbraco.DataLayer.dll -Force -Confirm:$false }
|
||||
|
||||
@@ -72,30 +72,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("TidyEditorContent")]
|
||||
internal InnerTextConfigurationElement<bool> TidyEditorContent
|
||||
{
|
||||
get
|
||||
{
|
||||
return new OptionalInnerTextConfigurationElement<bool>(
|
||||
(InnerTextConfigurationElement<bool>)this["TidyEditorContent"],
|
||||
//set the default
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("TidyCharEncoding")]
|
||||
internal InnerTextConfigurationElement<string> TidyCharEncoding
|
||||
{
|
||||
get
|
||||
{
|
||||
return new OptionalInnerTextConfigurationElement<string>(
|
||||
(InnerTextConfigurationElement<string>)this["TidyCharEncoding"],
|
||||
//set the default
|
||||
"UTF8");
|
||||
}
|
||||
}
|
||||
|
||||
[ConfigurationProperty("XmlCacheEnabled")]
|
||||
internal InnerTextConfigurationElement<bool> XmlCacheEnabled
|
||||
{
|
||||
@@ -333,17 +309,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
bool IContentSection.EnsureUniqueNaming
|
||||
{
|
||||
get { return EnsureUniqueNaming; }
|
||||
}
|
||||
|
||||
bool IContentSection.TidyEditorContent
|
||||
{
|
||||
get { return TidyEditorContent; }
|
||||
}
|
||||
|
||||
string IContentSection.TidyCharEncoding
|
||||
{
|
||||
get { return TidyCharEncoding; }
|
||||
}
|
||||
}
|
||||
|
||||
bool IContentSection.XmlCacheEnabled
|
||||
{
|
||||
|
||||
@@ -28,10 +28,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
|
||||
|
||||
bool EnsureUniqueNaming { get; }
|
||||
|
||||
bool TidyEditorContent { get; }
|
||||
|
||||
string TidyCharEncoding { get; }
|
||||
|
||||
bool XmlCacheEnabled { get; }
|
||||
|
||||
bool ContinouslyUpdateXmlDiskCache { get; }
|
||||
|
||||
@@ -35,13 +35,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).LengthFieldAlias == "umbracoBytes");
|
||||
Assert.IsTrue(SettingsSection.Content.ImageAutoFillProperties.ElementAt(0).ExtensionFieldAlias == "umbracoExtension");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public override void TidyCharEncoding()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.TidyCharEncoding == "UTF8");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public override void XmlContentCheckForDiskChanges()
|
||||
{
|
||||
|
||||
@@ -101,16 +101,7 @@ namespace Umbraco.Tests.Configurations.UmbracoSettings
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.EnsureUniqueNaming == true);
|
||||
}
|
||||
[Test]
|
||||
public void TidyEditorContent()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.TidyEditorContent == false);
|
||||
}
|
||||
[Test]
|
||||
public virtual void TidyCharEncoding()
|
||||
{
|
||||
Assert.IsTrue(SettingsSection.Content.TidyCharEncoding == "Raw");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void UseLegacyXmlSchema()
|
||||
{
|
||||
|
||||
@@ -47,12 +47,6 @@
|
||||
<!-- if true umbraco will ensure that no page under the same parent has an identical name -->
|
||||
<ensureUniqueNaming>True</ensureUniqueNaming>
|
||||
|
||||
<!-- clean editor content with use of tidy -->
|
||||
<TidyEditorContent>False</TidyEditorContent>
|
||||
|
||||
<!-- the encoding type for tidy. Default is UTF8, options are ASCII, Raw, Latin1, UTF8, ISO2022, MacroMan-->
|
||||
<TidyCharEncoding>UTF8</TidyCharEncoding>
|
||||
|
||||
<!-- to enable new content schema, this needs to be false -->
|
||||
<UseLegacyXmlSchema>false</UseLegacyXmlSchema>
|
||||
|
||||
|
||||
@@ -1843,18 +1843,6 @@ namespace umbraco
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Cleans the spified string with tidy
|
||||
/// </summary>
|
||||
/// <param name="StringToTidy">The string to tidy.</param>
|
||||
/// <param name="LiveEditing">if set to <c>true</c> [Live Editing].</param>
|
||||
/// <returns></returns>
|
||||
public static string Tidy(string StringToTidy, bool LiveEditing)
|
||||
{
|
||||
return cms.helpers.xhtml.TidyHtml(StringToTidy);
|
||||
}
|
||||
|
||||
internal static string GetCurrentNotFoundPageId()
|
||||
{
|
||||
//XmlNode error404Node = UmbracoSettings.GetKeyAsNode("/settings/content/errors/error404");
|
||||
|
||||
@@ -14,16 +14,6 @@ namespace umbraco.webservices
|
||||
[WebService(Namespace="http://umbraco.org/webservices/")]
|
||||
public class Developer : UmbracoAuthorizedWebService
|
||||
{
|
||||
|
||||
[WebMethod]
|
||||
public string BootStrapTidy(string html, string ContextID)
|
||||
{
|
||||
//pretty sure this is legacy and it used to throw an exception so we'll continue to do the same
|
||||
//true = throw if invalid
|
||||
AuthorizeRequest(true);
|
||||
|
||||
return cms.helpers.xhtml.BootstrapTidy(html);
|
||||
}
|
||||
|
||||
[WebMethod]
|
||||
public XmlNode GetMacros(string Login, string Password)
|
||||
|
||||
@@ -247,12 +247,6 @@ namespace umbraco.presentation.webservices
|
||||
|
||||
}
|
||||
|
||||
public string Tidy(string textToTidy)
|
||||
{
|
||||
AuthorizeRequest(true);
|
||||
return library.Tidy(helper.Request("StringToTidy"), true);
|
||||
}
|
||||
|
||||
private static string SaveCss(string fileName, string fileContents, int fileId)
|
||||
{
|
||||
string returnValue;
|
||||
|
||||
@@ -189,25 +189,7 @@ namespace umbraco
|
||||
public static bool CloneXmlCacheOnPublish
|
||||
{
|
||||
get { return UmbracoConfig.For.UmbracoSettings().Content.CloneXmlContent; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether rich text editor content should be parsed by tidy.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if content is parsed; otherwise, <c>false</c>.</value>
|
||||
public static bool TidyEditorContent
|
||||
{
|
||||
get { return UmbracoConfig.For.UmbracoSettings().Content.TidyEditorContent; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the encoding type for the tidyied content.
|
||||
/// </summary>
|
||||
/// <value>The encoding type as string.</value>
|
||||
public static string TidyCharEncoding
|
||||
{
|
||||
get { return UmbracoConfig.For.UmbracoSettings().Content.TidyCharEncoding; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the property context help option, this can either be 'text', 'icon' or 'none'
|
||||
|
||||
@@ -473,11 +473,11 @@ namespace umbraco.cms.businesslogic.template
|
||||
// test for macro alias
|
||||
if (elementName == "?UMBRACO_MACRO")
|
||||
{
|
||||
Hashtable tags = helpers.xhtml.ReturnAttributes(match.Value);
|
||||
var tags = XmlHelper.GetAttributesFromElement(match.Value);
|
||||
if (tags["macroAlias"] != null)
|
||||
elementAttributes = String.Format(" Alias=\"{0}\"", tags["macroAlias"].ToString()) + elementAttributes;
|
||||
elementAttributes = String.Format(" Alias=\"{0}\"", tags["macroAlias"]) + elementAttributes;
|
||||
else if (tags["macroalias"] != null)
|
||||
elementAttributes = String.Format(" Alias=\"{0}\"", tags["macroalias"].ToString()) + elementAttributes;
|
||||
elementAttributes = String.Format(" Alias=\"{0}\"", tags["macroalias"]) + elementAttributes;
|
||||
}
|
||||
string newElement = "<" + newElementName + " runat=\"server\" " + elementAttributes.Trim() + ">";
|
||||
if (elementAttributes.EndsWith("/"))
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using Umbraco.Core.Configuration;
|
||||
|
||||
|
||||
namespace umbraco.cms.helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Summary description for xhtml.
|
||||
/// </summary>
|
||||
public class xhtml
|
||||
{
|
||||
public xhtml()
|
||||
{
|
||||
//
|
||||
// TODO: Add constructor logic here
|
||||
//
|
||||
}
|
||||
|
||||
public static string TidyHtml(string html) {
|
||||
TidyNet.Tidy tidy = new TidyNet.Tidy();
|
||||
|
||||
/* Set the options you want */
|
||||
tidy.Options.DocType = TidyNet.DocType.Strict;
|
||||
tidy.Options.DropFontTags = true;
|
||||
tidy.Options.LogicalEmphasis = true;
|
||||
if (GlobalSettings.EditXhtmlMode == "true")
|
||||
{
|
||||
tidy.Options.Xhtml = true;
|
||||
tidy.Options.XmlOut = true;
|
||||
}
|
||||
else {
|
||||
tidy.Options.XmlOut = false;
|
||||
tidy.Options.Xhtml = false;
|
||||
}
|
||||
tidy.Options.MakeClean = true;
|
||||
tidy.Options.TidyMark = false;
|
||||
|
||||
// To avoid entity encoding
|
||||
tidy.Options.CharEncoding = (TidyNet.CharEncoding)Enum.Parse(typeof(TidyNet.CharEncoding), UmbracoConfig.For.UmbracoSettings().Content.TidyCharEncoding);
|
||||
|
||||
|
||||
/* Declare the parameters that is needed */
|
||||
TidyNet.TidyMessageCollection tmc = new TidyNet.TidyMessageCollection();
|
||||
MemoryStream input = new MemoryStream();
|
||||
MemoryStream output = new MemoryStream();
|
||||
|
||||
byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(html);
|
||||
input.Write(byteArray, 0, byteArray.Length);
|
||||
input.Position = 0;
|
||||
tidy.Parse(input, output, tmc);
|
||||
|
||||
string tidyed = System.Text.Encoding.UTF8.GetString(output.ToArray());
|
||||
|
||||
// only return body
|
||||
string regex = @"</{0,1}body[^>]*>";
|
||||
System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline)
|
||||
| System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options);
|
||||
string[] s = reg.Split(tidyed);
|
||||
if (s.Length > 1)
|
||||
return s[1];
|
||||
else
|
||||
return "[tidy error]";
|
||||
}
|
||||
|
||||
public static string BootstrapTidy(string html)
|
||||
{
|
||||
string emptyTags = ",br,hr,input,img,";
|
||||
string regex = "(<[^\\?][^(>| )]*>)|<([^\\?][^(>| )]*)([^>]*)>";
|
||||
Hashtable replaceTag = new Hashtable();
|
||||
replaceTag.Add("strong", "b");
|
||||
replaceTag.Add("em", "i");
|
||||
|
||||
System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline)
|
||||
| System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options);
|
||||
|
||||
foreach (Match m in reg.Matches(html))
|
||||
{
|
||||
string orgTag = "";
|
||||
string tag = "";
|
||||
string cleanTag = "";
|
||||
|
||||
if (m.Groups.Count < 2 || (m.Groups[2].Value.ToLower() != "img" || (m.Groups[2].Value.ToLower() == "img" && m.Value.IndexOf ("?UMBRACO_MACRO") == -1)))
|
||||
{
|
||||
|
||||
if (m.Groups[1].Value != "")
|
||||
{
|
||||
orgTag = m.Groups[1].Value;
|
||||
cleanTag = replaceTags(m.Groups[1].Value.ToLower().Replace("<", "").Replace("/>", "").Replace(">", "").Trim(), replaceTag);
|
||||
tag = "<" + cleanTag + ">";
|
||||
}
|
||||
else
|
||||
{
|
||||
orgTag = "<" + m.Groups[2].Value + m.Groups[3].Value + ">";
|
||||
|
||||
// loop through the attributes and make them lowercase
|
||||
cleanTag = replaceTags(m.Groups[2].Value.ToLower(), replaceTag);
|
||||
tag = "<" + cleanTag + returnLowerCaseAttributes(m.Groups[3].Value) + ">";
|
||||
}
|
||||
|
||||
// Check for empty tags
|
||||
if (bool.Parse(GlobalSettings.EditXhtmlMode) && emptyTags.IndexOf(","+cleanTag+",") > -1 && tag.IndexOf("/>") == -1)
|
||||
tag = tag.Replace(">", " />");
|
||||
|
||||
html = html.Replace(orgTag, tag);
|
||||
}
|
||||
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
private static string replaceTags(string tag, Hashtable replaceTag)
|
||||
{
|
||||
string closeBracket = "";
|
||||
if (tag.Substring(0,1) == "/")
|
||||
{
|
||||
closeBracket = "/";
|
||||
tag = tag.Substring(1, tag.Length-1);
|
||||
}
|
||||
|
||||
if (replaceTag.ContainsKey(tag))
|
||||
return closeBracket+replaceTag[tag].ToString();
|
||||
else
|
||||
return closeBracket+tag;
|
||||
}
|
||||
|
||||
[Obsolete("Has been superceded by Umbraco.Core.XmlHelper.GetAttributesFromElement")]
|
||||
public static Hashtable ReturnAttributes(String tag)
|
||||
{
|
||||
var h = new Hashtable();
|
||||
foreach (var i in Umbraco.Core.XmlHelper.GetAttributesFromElement(tag))
|
||||
{
|
||||
h.Add(i.Key, i.Value);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
private static string returnLowerCaseAttributes(String tag)
|
||||
{
|
||||
string newTag = "";
|
||||
MatchCollection m = Regex.Matches(tag, "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"|(?<attributeName>\\S*)=(?<attributeValue>[^( |>)]*)(>| )", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
|
||||
foreach (System.Text.RegularExpressions.Match attributeSet in m)
|
||||
newTag += " " + attributeSet.Groups["attributeName"].Value.ToString().ToLower() + "=\"" + attributeSet.Groups["attributeValue"].Value.ToString() + "\"";
|
||||
|
||||
return newTag;
|
||||
}
|
||||
|
||||
// helper method gotten from:
|
||||
// http://stackoverflow.com/questions/20762/how-do-you-remove-invalid-hexadecimal-characters-from-an-xml-based-data-source-p#comment8130028_641632
|
||||
internal static string RemoveIllegalXmlCharacters(string inString)
|
||||
{
|
||||
|
||||
if (inString == null) return null;
|
||||
|
||||
StringBuilder sbOutput = new StringBuilder();
|
||||
char ch;
|
||||
|
||||
for (int i = 0; i < inString.Length; i++)
|
||||
{
|
||||
ch = inString[i];
|
||||
if ((ch >= 0x0020 && ch <= 0xD7FF) ||
|
||||
(ch >= 0xE000 && ch <= 0xFFFD) ||
|
||||
ch == 0x0009 ||
|
||||
ch == 0x000A ||
|
||||
ch == 0x000D)
|
||||
{
|
||||
sbOutput.Append(ch);
|
||||
}
|
||||
}
|
||||
return sbOutput.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,4 @@
|
||||
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net40" />
|
||||
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
|
||||
<package id="SharpZipLib" version="0.86.0" targetFramework="net40" />
|
||||
<package id="Tidy.Net" version="1.0.0" targetFramework="net40" />
|
||||
</packages>
|
||||
@@ -167,10 +167,6 @@
|
||||
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
|
||||
</ProjectReference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="TidyNet, Version=1.0.0.0, Culture=neutral">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\packages\Tidy.Net.1.0.0\lib\TidyNet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SolutionInfo.cs">
|
||||
@@ -374,9 +370,6 @@
|
||||
<Compile Include="helpers\url.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="helpers\xhtml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="businesslogic\Packager\FileResources\Packages.config" />
|
||||
|
||||
Reference in New Issue
Block a user