Index: api/src/test/org/sakaiproject/entitybroker/EntityViewTest.java =================================================================== --- api/src/test/org/sakaiproject/entitybroker/EntityViewTest.java (revision 125660) +++ api/src/test/org/sakaiproject/entitybroker/EntityViewTest.java (working copy) @@ -316,6 +316,14 @@ assertEquals("this has spaces", ev.getPathSegment(3) ); assertEquals(null, ev.getPathSegment(4) ); + ev = new EntityView("/myprefix/myid/stuff/this_is_a_site.with.periods.in.the.name"); + assertNotNull(ev); + assertEquals("myprefix", ev.getPathSegment(0) ); + assertEquals("myid", ev.getPathSegment(1) ); + assertEquals("stuff", ev.getPathSegment(2) ); + assertEquals("this_is_a_site.with.periods.in.the.name", ev.getPathSegment(3) ); + assertEquals(null, ev.getPathSegment(4) ); + } public void testGetPathSegments() { Index: api/src/java/org/sakaiproject/entitybroker/util/TemplateParseUtil.java =================================================================== --- api/src/java/org/sakaiproject/entitybroker/util/TemplateParseUtil.java (revision 125660) +++ api/src/java/org/sakaiproject/entitybroker/util/TemplateParseUtil.java (working copy) @@ -21,15 +21,19 @@ package org.sakaiproject.entitybroker.util; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.UUID; import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.sakaiproject.entitybroker.EntityView; +import org.sakaiproject.entitybroker.entityprovider.extension.Formats; /** * Utility class to handle the URL template parsing (entity template parsing) @@ -142,6 +146,10 @@ * Stores the preloaded processed default templates */ public static final List defaultPreprocessedTemplates; + /** + * Contains a set of all the common extensions + */ + public static Set commonExtensions = new HashSet(20); // static initializer static { @@ -154,6 +162,21 @@ defaultTemplates.add( new Template(TEMPLATE_LIST, TEMPLATE_PREFIX) ); defaultPreprocessedTemplates = preprocessTemplates(defaultTemplates); + + // populate the list of common extensions + Collections.addAll(commonExtensions, Formats.JSON_EXTENSIONS); + Collections.addAll(commonExtensions, Formats.XML_EXTENSIONS); + Collections.addAll(commonExtensions, Formats.HTML_EXTENSIONS); + Collections.addAll(commonExtensions, Formats.FORM_EXTENSIONS); + Collections.addAll(commonExtensions, Formats.JSONP_EXTENSIONS); + Collections.addAll(commonExtensions, Formats.ATOM_EXTENSIONS); + Collections.addAll(commonExtensions, Formats.RSS_EXTENSIONS); + // also image extensions and other common ones + commonExtensions.add("png"); + commonExtensions.add("jpg"); + commonExtensions.add("gif"); + commonExtensions.add("jpeg"); + commonExtensions.add("csv"); } /** @@ -317,6 +340,11 @@ stripped = input.substring(0, extensionLoc); if ( (input.length() - 1) > extensionLoc) { extension = input.substring(extensionLoc + 1); + // we only consider it an extension if we recognize the type + if (!commonExtensions.contains(extension)) { + stripped = input; + extension = null; + } } } } Index: rest/src/test/org/sakaiproject/entitybroker/rest/EntityHandlerImplTest.java =================================================================== --- rest/src/test/org/sakaiproject/entitybroker/rest/EntityHandlerImplTest.java (revision 125660) +++ rest/src/test/org/sakaiproject/entitybroker/rest/EntityHandlerImplTest.java (working copy) @@ -149,7 +149,7 @@ } // types that cannot handle the return requested - req = new EntityHttpServletRequest("GET", DIRECT_PREFIX + TestData.REF4 + ".xxxx"); + req = new EntityHttpServletRequest("GET", DIRECT_PREFIX + TestData.REF4 + ".csv"); res = new EntityHttpServletResponse(); try { entityHandler.handleEntityAccess(req, res, null);