The BOSS is fixing U4-367

This commit is contained in:
NielsHartvig@UMBRACORATI.localdomain
2012-11-16 14:08:28 -01:00
parent b696aa4340
commit e122d40fb9
2 changed files with 39 additions and 4 deletions

View File

@@ -136,10 +136,22 @@ namespace umbraco.cms.businesslogic.datatype
{
//CHANGE:by Allan Laustsen to fix copy nodes
//if (value == null)
if (value == null || (string.IsNullOrEmpty(value.ToString()) && (this._dataType.DBType == DBTypes.Integer || this._dataType.DBType == DBTypes.Date)))
SqlHelper.ExecuteNonQuery("update cmsPropertyData set " + _dataType.DataFieldName + " = NULL where id = " + m_PropertyId);
if (value == null ||
(string.IsNullOrEmpty(value.ToString()) &&
(this._dataType.DBType == DBTypes.Integer || this._dataType.DBType == DBTypes.Date)))
SqlHelper.ExecuteNonQuery("update cmsPropertyData set " + _dataType.DataFieldName +
" = NULL where id = " + m_PropertyId);
else
SqlHelper.ExecuteNonQuery("update cmsPropertyData set " + _dataType.DataFieldName + " = @value where id = " + m_PropertyId, SqlHelper.CreateParameter("@value", value));
{
// we need to be sure that the value doesn't contain malformatted xml
if (_dataType.DBType == DBTypes.Ntext || _dataType.DBType == DBTypes.Nvarchar)
{
value = cms.helpers.xhtml.RemoveTroublesomeCharacters(value.ToString());
}
SqlHelper.ExecuteNonQuery(
"update cmsPropertyData set " + _dataType.DataFieldName + " = @value where id = " +
m_PropertyId, SqlHelper.CreateParameter("@value", value));
}
}
catch (Exception e)
{

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
@@ -146,6 +147,28 @@ namespace umbraco.cms.helpers
newTag += " " + attributeSet.Groups["attributeName"].Value.ToString().ToLower() + "=\"" + attributeSet.Groups["attributeValue"].Value.ToString() + "\"";
return newTag;
}
}
public static string RemoveTroublesomeCharacters(string inString)
{
if (inString == null) return null;
StringBuilder newString = new StringBuilder();
char ch;
for (int i = 0; i < inString.Length; i++)
{
ch = inString[i];
// remove any characters outside the valid UTF-8 range as well as all control characters
// except tabs and new lines
if ((ch < 0x00FD && ch > 0x001F) || ch == '\t' || ch == '\n' || ch == '\r')
{
newString.Append(ch);
}
}
return newString.ToString();
}
}
}