Skip to content

Commit 8f6d90c

Browse files
committed
Add i18n support to all uses of pathCheck
1 parent b759495 commit 8f6d90c

1 file changed

Lines changed: 24 additions & 6 deletions

File tree

java/org/apache/catalina/manager/host/HostManagerServlet.java

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -374,14 +374,14 @@ protected synchronized void add(PrintWriter writer, String name, String aliases,
374374
}
375375

376376
// Create base for config files
377-
File configBaseFile = getConfigBase(name);
377+
File configBaseFile = getConfigBase(name, writer, smClient);
378+
if (configBaseFile == null) {
379+
writer.println(smClient.getString("hostManagerServlet.configBaseCreateFail", name));
380+
return;
381+
}
378382

379383
// Copy manager.xml if requested
380384
if (manager) {
381-
if (configBaseFile == null) {
382-
writer.println(smClient.getString("hostManagerServlet.configBaseCreateFail", name));
383-
return;
384-
}
385385
try (InputStream is = getServletContext().getResourceAsStream("/WEB-INF/manager.xml")) {
386386
if (is == null) {
387387
writer.println(smClient.getString("hostManagerServlet.managerXml"));
@@ -651,8 +651,26 @@ protected void persist(PrintWriter writer, StringManager smClient) {
651651
* @param hostName The host name
652652
*
653653
* @return the config base for the host
654+
*
655+
* @deprecated Unused. Will be removed in Tomcat 12. Use {@link #getConfigBase(String, PrintWriter, StringManager)}
654656
*/
657+
@Deprecated
655658
protected File getConfigBase(String hostName) {
659+
return getConfigBase(hostName, null, null);
660+
}
661+
662+
663+
/**
664+
* Get config base.
665+
*
666+
* @param hostName The host name
667+
* @param writer Writer to render results to
668+
* @param smClient StringManager for the client's locale
669+
*
670+
*
671+
* @return the config base for the host
672+
*/
673+
protected File getConfigBase(String hostName, PrintWriter writer, StringManager smClient) {
656674
File configBase = new File(context.getCatalinaBase(), "conf");
657675
if (!configBase.exists()) {
658676
return null;
@@ -663,7 +681,7 @@ protected File getConfigBase(String hostName) {
663681
if (installedHost != null) {
664682
configBase = new File(configBase, hostName);
665683
}
666-
if (!pathCheck(configBase, new File(context.getCatalinaBase(), "conf"), null, null)) {
684+
if (!pathCheck(configBase, new File(context.getCatalinaBase(), "conf"), writer, smClient)) {
667685
return null;
668686
}
669687
if (!configBase.mkdirs() && !configBase.isDirectory()) {

0 commit comments

Comments
 (0)