<fim-prefix> }

        return skin;
    }

    @Override
    public Resource<?> getLocalResource(String resourceName)
    {
        String resourcePath = getSkinResourcePath(resourceName);

        if (resourcePath != null && getResourceURL(resourcePath) != null) {
            return createResource(resourcePath, resourceName);
        }

        return null;
    }

    protected String getPropertiesPath()
    {
        return getSkinFolder() + "skin.properties";
    }

    protected String getSkinFolder()
    {
        return "skins/" + this.id + '/';
    }

    protected Configuration getProperties()
    {
        if (this.properties == null) {
            URL url = getResourceURL(getPropertiesPath());
            if (url != null) {
                try {
                    this.properties = new Configurations().properties(url);
                } catch (ConfigurationException e) {
                    LOGGER.error("Failed to load skin [{}] properties file ([])", this.id, url,
                        getRootCauseMessage(e));

                    this.properties = new BaseConfiguration();
                }
            } else {
                LOGGER.debug("No properties found for skin [{}]", this.id);

                this.properties = new BaseConfiguration();
            }
        }

        return this.properties;
    }

    private String getSkinResourcePath(String resource)
    {
        String skinFolder = getSkinFolder();
        String resourcePath = skinFolder + resource;
        // BUG: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
        // // Prevent inclusion of templates from other directories
        // FIXED:
 <fim-middle>       // Prevent access to resources from other directories
        Path normalizedResource = Paths.get(resourcePath).normalize();
        // Protect against directory attacks.
        if (!normalized<fix-suffix>Resource.startsWith(skinFolder)) {
            LOGGER.warn("Direct access to skin file [{}] refused. Possible break-in attempt!", normalizedResource);
            return null;
        }

        return resourcePath;
    }
}
<|endoftext|>