fix(cafe24): 디자인 FTP 임시 파일이 확장자 제한에 걸려 적용 실패
카페24 디자인 FTP 는 허용 확장자만 받는다. 임시 이름 `product-swiper.js.cf24tmp-<tag>` 는 확장자가 바뀌어 STOR 가 `550 Operation not permitted` 로 거부돼 모바일 스와이프·PC/모바일 상품상세 적용이 모두 실패했다. 원래 확장자를 끝에 두도록 `<stem>_cf24tmp_<tag><ext>` 로 바꾼다(원본 비킴 이름도 동일). 테스트 FTP 대역에 확장자 제한을 흉내내 회귀를 막는다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -478,10 +478,20 @@ class FakeFTP:
|
||||
raise ftplib.error_perm("550 No such file")
|
||||
callback(self.files[path])
|
||||
|
||||
# 카페24 디자인 FTP 는 허용 확장자만 받는다(실물: `x.js.cf24tmp-…` STOR → 550).
|
||||
ALLOWED_EXT = (".js", ".html", ".htm", ".css", ".json", ".txt", ".xml",
|
||||
".jpg", ".jpeg", ".gif", ".png", ".svg", ".webp")
|
||||
|
||||
@classmethod
|
||||
def _check_ext(cls, path):
|
||||
if not path.lower().endswith(cls.ALLOWED_EXT):
|
||||
raise ftplib.error_perm(f"550 {path}: Operation not permitted")
|
||||
|
||||
def storbinary(self, cmd, fp):
|
||||
path = cmd.split(" ", 1)[1]
|
||||
data = fp.read()
|
||||
FakeFTP.log.append(("STOR", path))
|
||||
self._check_ext(path)
|
||||
self.files[path] = data[: len(data) // 2] if FakeFTP.truncate_store else data
|
||||
|
||||
def rename(self, src, dst):
|
||||
@@ -493,6 +503,7 @@ class FakeFTP:
|
||||
raise ftplib.error_perm("502 RNFR not implemented")
|
||||
if src not in self.files:
|
||||
raise ftplib.error_perm("550 No such file")
|
||||
self._check_ext(dst)
|
||||
if dst in self.files and FakeFTP.rename_mode == "no_overwrite":
|
||||
raise ftplib.error_perm("553 File exists")
|
||||
self.files[dst] = self.files.pop(src)
|
||||
|
||||
Reference in New Issue
Block a user