nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.51k stars 4.08k forks source link

fix(TemplateManager): Make sure TemplateFolder is a Folder #49451

Open solracsf opened 2 days ago

solracsf commented 2 days ago

Checklist

joshtrichards commented 2 days ago

LOL I just wrote basically the same code and was about to shoot over the PR:

    private function getTemplateFolder(): Node {
        if ($this->getTemplatePath() !== '') {
            $userTemplateFolder = $this->rootFolder->getUserFolder($this->userId)->get($this->getTemplatePath());
            if ($userTemplateFolder->getType() === \OCP\Files\FileInfo::TYPE_FOLDER) {
                return $userTemplateFolder;
            }
        }
        throw new NotFoundException();
    }

Both re-trigger the new template folder setup setting (good). I didn't make the exception message more verbose though. Since it's caught silently when used in getTemplateFiles() I think re-triggering the Create new template folder option is enough (but won't hurt!).