Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

91710: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud)
      91606: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1)
         << Merging only new CMIS >>  
         91469: Merged V4.2.4 (4.2.4) to V4.2-BUG-FIX (4.2.5)
            91306: Merged DEV to PATCHES/4.2.4
               91267 : MNT-12496: CMIS: Unable to navigate to a folder if it has image with special character on the metadata
                  - Escaping of control characters was added
               91286 : MNT-12496: CMIS: Unable to navigate to a folder if it has image with special character on the metadata
                  - Added tests to check incorrect char in description property of node.
         91470: Merged V4.2.4 (4.2.4) to V4.2-BUG-FIX (4.2.5)
            91313: MNT-12496: CMIS: Unable to navigate to a folder if it has image with special character on the metadata
               - Build failure fixed


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94826 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 11:37:48 +00:00
parent a5fd70c692
commit 63b9af8925

View File

@@ -2118,7 +2118,16 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return df.newXMLGregorianCalendar((GregorianCalendar) value).toXMLFormat();
}
return value.toString();
// MNT-12496
// Encode for AtomPub only. Browser/json binding already encodes.
if (AlfrescoCmisServiceCall.get() != null && CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()))
{
return escapeControlCharacters(value.toString());
}
else
{
return value.toString();
}
}
@SuppressWarnings("unchecked")
@@ -2213,7 +2222,16 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
else
{
((PropertyStringImpl) result).setValue((String) value);
// MNT-12496
// Encode for AtomPub only. Browser/json binding already encodes.
if (AlfrescoCmisServiceCall.get() != null && CallContext.BINDING_ATOMPUB.equals(AlfrescoCmisServiceCall.get().getBinding()))
{
((PropertyStringImpl) result).setValue(escapeControlCharacters((String) value));
}
else
{
((PropertyStringImpl) result).setValue((String) value);
}
}
break;
case URI:
@@ -2241,6 +2259,47 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return result;
}
private String escapeControlCharacters(String origValue)
{
if (origValue == null)
{
return origValue;
}
StringBuilder sb = new StringBuilder();
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);
}
}
}
return sb.toString();
}
private Set<String> splitFilter(String filter)
{