epugh commented on code in PR #4203:
URL: https://github.com/apache/solr/pull/4203#discussion_r3448582305
##########
solr/core/src/java/org/apache/solr/handler/configsets/DownloadConfigSet.java:
##########
@@ -63,20 +63,34 @@ public Response downloadConfigSet(String configSetName)
throws Exception {
throw new SolrException(
SolrException.ErrorCode.NOT_FOUND, "ConfigSet " + configSetName + "
not found!");
}
- return buildZipResponse(configSetService, configSetName);
+ return buildZipResponse(configSetService, configSetName,
deriveDisplayName(configSetName));
+ }
+
+ // This is to support the schema designer's internal name and
+ // lets us not duplicate the download endpoint.
+ static String deriveDisplayName(String configSetName) {
+ if (configSetName.startsWith("._designer_")) {
+ return configSetName.substring("._designer_".length());
+ }
+ return configSetName;
}
/**
* Build a ZIP download {@link Response} for the given configset.
*
* @param configSetService the service to use for downloading the configset
files
- * @param configSetName the name of the configset to download
+ * @param configSetName the name of the configset to download (internal id)
+ * @param displayName the sanitized name to use in the Content-Disposition
filename
*/
- public static Response buildZipResponse(ConfigSetService configSetService,
String configSetName)
+ public static Response buildZipResponse(
+ ConfigSetService configSetService, String configSetName, String
displayName)
throws IOException {
final byte[] zipBytes = zipConfigSet(configSetService, configSetName);
+ final String safeName = displayName.replaceAll("[^a-zA-Z0-9_\\-.]", "_");
+ final String fileName = safeName + "_configset.zip";
return Response.ok((StreamingOutput) outputStream ->
outputStream.write(zipBytes))
.type("application/zip")
+ .header("Content-Disposition", "attachment; filename=\"" + fileName +
"\"")
Review Comment:
this branch diverged before the work in 4264, so I need to bring htose
updates in.. I though when I merged from `main` it would, but there is still
some work.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]