Merged 5.1.N (5.1.1) to HEAD (5.1)

117597 adavis: Merged 5.0.N (5.0.3) to 5.1.N (5.1.1)
      117582 adavis: Merged V4.2-BUG-FIX (4.2.6) to 5.0.N (5.0.3) (PARTIAL MERGE)
         116652 amorarasu: MNT-14983: CMIS: Euro character not encoded correctly
            Merged V4.2.4 (4.2.4.19) to V4.2-BUG-FIX (4.2.6)
               115140 115998 116396 amorarasu: MNT-15044: CLONE - CMIS: Euro character not encoded correctly
                  - Removed the unicode interval that was used to escape characters from the categories: currency, general punctuation, subscripts and superscripts (2000-20FF).
                  - Changed the way the control characters are filtered + adapted tests.
                  - Removed unnecessary j_string use from the ftl and added proper xml encoding.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@123586 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-03-11 17:27:03 +00:00
parent 65918ed209
commit a9e033f2c5
2 changed files with 24 additions and 42 deletions

View File

@@ -2807,7 +2807,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
// general properties
info.setObject(object);
info.setId(object.getId());
info.setName(ni.getName());
info.setName(getStringProperty(object, PropertyIds.NAME));
info.setCreatedBy(getStringProperty(object, PropertyIds.CREATED_BY));
info.setCreationDate(getDateTimeProperty(object, PropertyIds.CREATION_DATE));
info.setLastModificationDate(getDateTimeProperty(object, PropertyIds.LAST_MODIFICATION_DATE));

View File

@@ -255,6 +255,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
public static final char ID_SEPERATOR = ';';
public static final char REPLACEMENT_CHAR = '_';
public static final String ASSOC_ID_PREFIX = "assoc:";
public static final String PWC_VERSION_LABEL = "pwc";
public static final String UNVERSIONED_VERSION_LABEL = "1.0";
@@ -2093,11 +2094,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat();
}
// MNT-12496
// Encode for AtomPub only. Browser/json binding already encodes.
if (AlfrescoCmisServiceCall.get() != null && CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()))
// MNT-12496 MNT-15044
// Filter for AtomPub and Web services bindings only. Browser/json binding already encodes.
if (AlfrescoCmisServiceCall.get() != null &&
(CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) ||
CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding())))
{
return escapeControlCharacters(value.toString());
return filterXmlRestrictedCharacters(value.toString());
}
else
{
@@ -2197,11 +2200,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
else
{
// MNT-12496
// Encode for AtomPub only. Browser/json binding already encodes.
if (AlfrescoCmisServiceCall.get() != null && CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()))
// MNT-12496 MNT-15044
// Filter for AtomPub and Web services bindings only. Browser/json binding already encodes.
if (AlfrescoCmisServiceCall.get() != null &&
(CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()) ||
CallContext.BINDING_WEBSERVICES.equals(AlfrescoCmisServiceCall.get().getBinding())))
{
((PropertyStringImpl) result).setValue(escapeControlCharacters((String) value));
((PropertyStringImpl) result).setValue(filterXmlRestrictedCharacters((String) value));
}
else
{
@@ -2235,7 +2240,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return result;
}
private String escapeControlCharacters(String origValue)
private String filterXmlRestrictedCharacters(String origValue)
{
if (origValue == null)
{
@@ -2246,33 +2251,10 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
for (int i = 0; i < origValue.length(); i++)
{
char ch = origValue.charAt(i);
switch (ch)
{
case '\b':
case '\f':
case '\n':
case '\r':
case '\t':
sb.append(ch);
break;
default:
// Reference: http://www.unicode.org/versions/Unicode5.1.0/
if ((ch >= '\u0000' && ch <= '\u001F') || (ch >= '\u007F' && ch <= '\u009F') || (ch >= '\u2000' && ch <= '\u20FF'))
{
String ss = Integer.toHexString(ch);
sb.append("\\u");
for (int k = 0; k < 4 - ss.length(); k++)
{
sb.append('0');
}
sb.append(ss.toUpperCase());
}
else
{
sb.append(ch);
}
}
boolean restricted = (ch < '\u0020') && !(ch == '\t' || ch == '\n' || ch == '\r');
sb.append(restricted ? REPLACEMENT_CHAR : ch);
}
return sb.toString();
}