Skip to content

Commit

Permalink
🔒 对于文件所在合法目录判断上的缺陷 #76
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jun 9, 2023
1 parent fee069d commit d604a3a
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 3.0.0.0, Feb 11, 2020
* @version 3.0.1.0, Jun 9, 2023
* @since 1.4.0
*/
@Singleton
Expand Down Expand Up @@ -116,7 +116,7 @@ public void getFile(final RequestContext context) {
try {
if (!FileUtil.isExistingFile(new File(path)) ||
!FileUtil.isExistingFolder(new File(Symphonys.UPLOAD_LOCAL_DIR)) ||
!new File(path).getCanonicalPath().startsWith(new File(Symphonys.UPLOAD_LOCAL_DIR).getCanonicalPath())) {
!Path.of(path).normalize().startsWith(Path.of(Symphonys.UPLOAD_LOCAL_DIR).normalize())) {
context.sendError(404);
return;
}
Expand Down

0 comments on commit d604a3a

Please sign in to comment.