Merged V3.3-BUG-FIX to HEAD

21634: Fix ALF-3822: Storing of datetime does not work
   21646: ALF-3752: Getting Parent on a specific version throws exception
   21655: Fix ALF-4006: Incorrect search result after renaming a folder
   21659: Workaround for ALF-4230: use of flash technology to upload documents into a share site makes the use of (some) external authentication methods difficult (or impossible)
      - The Flash uploader can be disabled via share-config: DocumentLibary / file-upload / adobe-flash-enabled
   21675: AVM - build/test fix (testSubmitUpdatedItemWithLF)
   21687: Merged V3.3 to V3.3-BUG-FIX
      21650: Fix for ALF-4239: Cannot open any folder that contains a node that is neither folder nor content in Share repo browser
      21658: Merged HEAD to BRANCHES/V3.3:
         21557: Fix ALF-4141: Cannot create relationship via OpenCMIS
      21673: ALF-1905: Corrected LDAP connection validation to allow synchronization connection to use anonymous bind
      21686: Merged PATCHES/V3.3.1 to V3.3
         21684: ALF-4039: Use ISO 9705-style encoding to ensure that compound WCM store names do not collide when user names contain illegal characters
            - Previously, characters that were illegal were just replaced with _ so there could be collisions in store names
            - Also, the sequence -- in a user name or user names "preview" and "workflow" would have been problematic.
         21535: (RECORD ONLY) Merged V3.3 to PATCHES/V3.3.1
            20778: Added revision to version label.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21689 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Dave Ward
2010-08-09 15:28:11 +00:00
parent b51e8ef744
commit 420caeac25
6 changed files with 147 additions and 41 deletions

View File

@@ -195,9 +195,8 @@ public class WCMUtil extends AVMUtil
storeName = WCMUtil.getCorrespondingMainStoreName(storeName);
}
final int index = storeName.indexOf(WCMUtil.STORE_SEPARATOR);
return (index == -1
? null
: storeName.substring(index + WCMUtil.STORE_SEPARATOR.length()));
return (index == -1 ? null : unescapeStoreNameComponent(storeName.substring(index
+ WCMUtil.STORE_SEPARATOR.length())));
}
/**
@@ -303,6 +302,104 @@ public class WCMUtil extends AVMUtil
return (buildAVMPath(otherStoreName, WCMUtil.getStoreRelativePath(avmPath)));
}
/**
* Utility function for escaping part of a compound store name (delimited by STORE_SEPARATOR sequences). Uses ISO
* 9075 style encoding to escape otherwise problematic character sequences.
*
* @param component
* the component
* @return the escaped string
*/
private static final String escapeStoreNameComponent(String component)
{
StringBuilder builder = null;
int length = component.length();
// If the component matches one of the common suffixes, encode it
if (component.equals(STORE_PREVIEW) || component.equals(STORE_WORKFLOW))
{
builder = new StringBuilder(length + 5);
appendEncoded(builder, component);
return builder.toString();
}
// Look for problematic character sequences
Matcher matcher = PATTERN_ILLEGAL_SEQUENCE.matcher(component);
int lastAppendPosition = 0;
while (matcher.find())
{
if (builder == null)
{
builder = new StringBuilder(length + 5);
}
if (matcher.start() != lastAppendPosition)
{
builder.append(component, lastAppendPosition, matcher.start());
}
lastAppendPosition = matcher.end();
appendEncoded(builder, matcher.group());
}
if (builder == null)
{
return component;
}
if (lastAppendPosition < length)
{
builder.append(component, lastAppendPosition, length);
}
return builder.toString();
}
/**
* Utility function for decoding from Strings produced by the above method.
*
* @param component
* the encoded component
* @return the decoded component
*/
private static String unescapeStoreNameComponent(String component)
{
StringBuilder builder = null;
int length = component.length();
int lastAppendPosition = 0;
int escapeIndex;
while ((escapeIndex = component.indexOf("_x", lastAppendPosition)) != -1)
{
if (builder == null)
{
builder = new StringBuilder(length + 5);
}
if (escapeIndex != lastAppendPosition)
{
builder.append(component, lastAppendPosition, escapeIndex);
}
lastAppendPosition = component.indexOf('_', escapeIndex + 2);
builder.appendCodePoint(Integer.parseInt(component.substring(escapeIndex + 2, lastAppendPosition), 16));
lastAppendPosition++;
}
if (builder == null)
{
return component;
}
if (lastAppendPosition < length)
{
builder.append(component, lastAppendPosition, length);
}
return builder.toString();
}
private static final void appendEncoded(StringBuilder builder, String sequence)
{
builder.append("_x").append(Integer.toString(sequence.codePointAt(0), 16).toUpperCase()).append("_");
int length = sequence.length();
int next = sequence.offsetByCodePoints(0, 1);
if (next < length)
{
builder.append(sequence, next, length);
}
}
/**
* Returns the main staging store name for the specified web project
*
@@ -340,7 +437,7 @@ public class WCMUtil extends AVMUtil
final String userName)
{
ParameterCheck.mandatoryString("userName", userName);
String fixedUserName = FileNameValidator.getValidFileName(userName);
String fixedUserName = escapeStoreNameComponent(userName);
return (WCMUtil.buildStagingStoreName(storeId) + WCMUtil.STORE_SEPARATOR +
fixedUserName);
}
@@ -753,6 +850,9 @@ public class WCMUtil extends AVMUtil
// Component Separator.
protected static final String STORE_SEPARATOR = "--";
/** Matches character sequences that must be escaped in a compound store name. */
protected static final Pattern PATTERN_ILLEGAL_SEQUENCE = Pattern.compile(FileNameValidator.FILENAME_ILLEGAL_REGEX + "|_x|" + STORE_SEPARATOR);
// names of the stores representing the layers for an AVM website
//XXXarielb this should be private