Skip to content

Commit

Permalink
Merge pull request sakura-editor#409 from beru/reject_LFN
Browse files Browse the repository at this point in the history
ファイルを開く、で _MAX_PATH (260) より長いパスのファイルの場合はエラーメッセージを出して処理を中断
  • Loading branch information
beru authored Sep 12, 2018
2 parents e266088 + d627ea1 commit a4008f0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sakura_core/String_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -1385,5 +1385,6 @@
#define STR_KEYHELP_RMENU_NONE 35029
#define STR_KEYHELP_RMENU_TOP 35030
#define STR_KEYHELP_RMENU_BOTTOM 35031
#define STR_ERR_FILEPATH_TOO_LONG 35034

// Now using max number 35033 by STR_LOADAGENT_BIG_ERROR
// Now using max number 35034 by STR_ERR_FILEPATH_TOO_LONG
10 changes: 10 additions & 0 deletions sakura_core/cmd/CViewCommander_File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ void CViewCommander::Command_FILEOPEN( const WCHAR* filename, ECodeType nCharCod
);
if(!bDlgResult)return;

for(size_t i = 0; i < files.size(); i++ ){
if (files[i].length() >= _MAX_PATH){
ErrorMessage(
CEditWnd::getInstance()->GetHwnd(),
LS(STR_ERR_FILEPATH_TOO_LONG),
files[i].c_str()
);
return;
}
}
sLoadInfo.cFilePath = files[0].c_str();
// 他のファイルは新規ウィンドウ
int nSize = (int)files.size();
Expand Down
2 changes: 2 additions & 0 deletions sakura_core/sakura_rc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,8 @@ GDI リソース\t残り %d%%\n\n"
STR_FILETREE_REPLACE_PATH_FROM "置換元パスを指定してください"
STR_FILETREE_REPLACE_PATH_TO "置換先文字列を指定してください"

STR_ERR_FILEPATH_TOO_LONG "%ls\nというファイルを開けません。\nファイルのパスが長すぎます。"

END

STRINGTABLE DISCARDABLE
Expand Down
3 changes: 3 additions & 0 deletions sakura_lang_en_US/sakura_lang_rc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -4132,6 +4132,9 @@ GDI Resource\tRemaining %d%%\n\n"
STR_FILETREE_REPLACE_PATH_FROM "Please Input Replace 'From' Path"
STR_FILETREE_REPLACE_PATH_TO "Please Input Replace 'To' Path"

STR_ERR_FILEPATH_TOO_LONG "'%ts'\nCannot open the file.\nThe filepath is too long."


END

STRINGTABLE DISCARDABLE
Expand Down

0 comments on commit a4008f0

Please sign in to comment.