Fix for ETWOTWO-400 : Group names can not contain "

- authority service find query now uses lucene to escape all chars in the phrases it builds for user and people search.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19968 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2010-04-23 11:28:39 +00:00
parent 20d8a16fbd
commit 6f82287b74
2 changed files with 11 additions and 4 deletions

View File

@@ -315,7 +315,7 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
query.append(" AND @").append( query.append(" AND @").append(
LuceneQueryParser.escape("{" + ContentModel.PROP_USERNAME.getNamespaceURI() + "}" LuceneQueryParser.escape("{" + ContentModel.PROP_USERNAME.getNamespaceURI() + "}"
+ ISO9075.encode(ContentModel.PROP_USERNAME.getLocalName()))).append(":\"").append( + ISO9075.encode(ContentModel.PROP_USERNAME.getLocalName()))).append(":\"").append(
displayNamePattern).append("\""); LuceneQueryParser.escape(displayNamePattern)).append("\"");
} }
if (type == null) if (type == null)
@@ -334,16 +334,16 @@ public class AuthorityDAOImpl implements AuthorityDAO, NodeServicePolicies.Befor
// Allow for the appropriate type prefix in the authority name // Allow for the appropriate type prefix in the authority name
if (type == null && !displayNamePattern.startsWith("*")) if (type == null && !displayNamePattern.startsWith("*"))
{ {
query.append("*").append(displayNamePattern); query.append("*").append(LuceneQueryParser.escape(displayNamePattern));
} }
else else
{ {
query.append(getName(type, displayNamePattern)); query.append(getName(type, LuceneQueryParser.escape(displayNamePattern)));
} }
query.append("\" OR @").append( query.append("\" OR @").append(
LuceneQueryParser.escape("{" + ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getNamespaceURI() + "}" LuceneQueryParser.escape("{" + ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getNamespaceURI() + "}"
+ ISO9075.encode(ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getLocalName()))).append( + ISO9075.encode(ContentModel.PROP_AUTHORITY_DISPLAY_NAME.getLocalName()))).append(
":\"").append(displayNamePattern).append("\")"); ":\"").append(LuceneQueryParser.escape(displayNamePattern)).append("\")");
} }
if (type == null) if (type == null)
{ {

View File

@@ -239,6 +239,13 @@ public class AuthorityServiceTest extends TestCase
assertEquals(1, pubAuthorityService.getAllRootAuthoritiesInZone("Three", AuthorityType.GROUP).size()); assertEquals(1, pubAuthorityService.getAllRootAuthoritiesInZone("Three", AuthorityType.GROUP).size());
} }
public void test_ETWOTWO_400()
{
String auth = pubAuthorityService.createAuthority(AuthorityType.GROUP, "wo\"of");
Set<String> authorities = pubAuthorityService.findAuthorities(AuthorityType.GROUP, null, true, "wo\"of*", AuthorityService.ZONE_APP_DEFAULT);
assertEquals(1, authorities.size());
}
public void testGroupWildcards() public void testGroupWildcards()
{ {
long before, after; long before, after;