Search in sources :

Example 1 with ToDownload

use of com.github.zhanhb.download.spring.ToDownload in project judge by zjnu-acm.

the class CKFinderController method ckfinder.

@Nullable
@ToDownload
@GetMapping("/support/ckfinder")
public Path ckfinder(@RequestParam("path") String path) {
    log.info(path);
    try {
        int indexOf = path.indexOf('?');
        Path parent = judgeConfiguration.getUploadDirectory();
        Path imagePath = parent.getFileSystem().getPath(parent.toString(), indexOf > 0 ? path.substring(0, indexOf) : path).normalize();
        if (!imagePath.startsWith(parent)) {
            log.debug("absolute path parent='{}' path='{}'", parent, imagePath);
            return null;
        }
        return imagePath;
    } catch (IllegalArgumentException ex) {
        return null;
    }
}
Also used : Path(java.nio.file.Path) GetMapping(org.springframework.web.bind.annotation.GetMapping) ToDownload(com.github.zhanhb.download.spring.ToDownload) Nullable(javax.annotation.Nullable)

Aggregations

ToDownload (com.github.zhanhb.download.spring.ToDownload)1 Path (java.nio.file.Path)1 Nullable (javax.annotation.Nullable)1 GetMapping (org.springframework.web.bind.annotation.GetMapping)1