Skip to content

Commit

Permalink
don't forget to call Py_FinalizeEx after Py_InitializeEx
Browse files Browse the repository at this point in the history
make PyObjectPtr noncopyable

auto call Py_XDECREF

show error message when LodLibrary fails

CPythonMacroManager.cpp で g_pEditView グローバル変数を使うのを止める
警告除去

remove unused utf8_to_utf16le function

show Python error message with MessageBox

use LoadLibraryExedir function

use PyErr_Fetch to get error message string

detect and erase UTF-8 BOM from fread string in CPythonMacroManager::LoadKeyMacro

use UTF-8 encoding string for filename argument of Py_CompileString function

add error checks

update handleFunction to use PyUnicode_AsWideCharString instead of PyUnicode_AsUTF8AndSize

use case-insensitive string comparison for python file extension

add file open error check in CPythonMacroManager::LoadKeyMacro method

call GetProcAddress only after DLL is loaded

use PyUnicode_AsUTF8AndSize instead of PyUnicode_AsUTF8 so that vulnerable strlen can be avoided
explicitly cast function pointer to void* before copying it to void* type variable

マクロの Python 対応
  • Loading branch information
beru committed Sep 22, 2024
1 parent 53ea30b commit 96bbe32
Show file tree
Hide file tree
Showing 8 changed files with 1,195 additions and 4 deletions.
2 changes: 2 additions & 0 deletions sakura/sakura.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@
<ClInclude Include="..\sakura_core\macro\CMacroManagerBase.h" />
<ClInclude Include="..\sakura_core\macro\CPPA.h" />
<ClInclude Include="..\sakura_core\macro\CPPAMacroMgr.h" />
<ClInclude Include="..\sakura_core\macro\CPythonMacroManager.h" />
<ClInclude Include="..\sakura_core\macro\CSMacroMgr.h" />
<ClInclude Include="..\sakura_core\macro\CWSH.h" />
<ClInclude Include="..\sakura_core\macro\CWSHIfObj.h" />
Expand Down Expand Up @@ -708,6 +709,7 @@
<ClCompile Include="..\sakura_core\macro\CMacroManagerBase.cpp" />
<ClCompile Include="..\sakura_core\macro\CPPA.cpp" />
<ClCompile Include="..\sakura_core\macro\CPPAMacroMgr.cpp" />
<ClCompile Include="..\sakura_core\macro\CPythonMacroManager.cpp" />
<ClCompile Include="..\sakura_core\macro\CSMacroMgr.cpp" />
<ClCompile Include="..\sakura_core\macro\CWSH.cpp" />
<ClCompile Include="..\sakura_core\macro\CWSHIfObj.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions sakura/sakura.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,9 @@
<ClInclude Include="..\sakura_core\parse\DetectIndentationStyle.h">
<Filter>Cpp Source Files\parse</Filter>
</ClInclude>
<ClInclude Include="..\sakura_core\macro\CPythonMacroManager.h">
<Filter>Cpp Source Files\macro</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\resource\auto_scroll_center.cur">
Expand Down Expand Up @@ -2321,6 +2324,9 @@
<ClCompile Include="..\sakura_core\parse\DetectIndentationStyle.cpp">
<Filter>Cpp Source Files\parse</Filter>
</ClCompile>
<ClCompile Include="..\sakura_core\macro\CPythonMacroManager.cpp">
<Filter>Cpp Source Files\macro</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Image Include="..\resource\auto_scroll_center.bmp">
Expand Down
3 changes: 2 additions & 1 deletion sakura_core/dlg/CDlgOpenFile_CommonFileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,10 +726,11 @@ bool CDlgOpenFile_CommonFileDialog::DoModal_GetOpenFileName( WCHAR* pszPath, EFi
cFileExt.AppendExtRaw( LS(STR_DLGOPNFL_EXTNAME2), L"*.txt" );
break;
case EFITER_MACRO:
cFileExt.AppendExtRaw( L"Macros", L"*.js;*.vbs;*.ppa;*.mac" );
cFileExt.AppendExtRaw( L"Macros", L"*.js;*.vbs;*.ppa;*.py;*.mac" );
cFileExt.AppendExtRaw( L"JScript", L"*.js" );
cFileExt.AppendExtRaw( L"VBScript", L"*.vbs" );
cFileExt.AppendExtRaw( L"Pascal", L"*.ppa" );
cFileExt.AppendExtRaw( L"Python", L"*.py" );
cFileExt.AppendExtRaw( L"Key Macro", L"*.mac" );
break;
case EFITER_NONE:
Expand Down
3 changes: 2 additions & 1 deletion sakura_core/dlg/CDlgOpenFile_CommonItemDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,11 @@ bool CDlgOpenFile_CommonItemDialog::DoModal_GetOpenFileName( WCHAR* pszPath, EFi
specs.push_back(COMDLG_FILTERSPEC{strs.back().c_str(), L"*.txt"});
break;
case EFITER_MACRO:
specs.push_back(COMDLG_FILTERSPEC{L"Macros", L"*.js;*.vbs;*.ppa;*.mac"});
specs.push_back(COMDLG_FILTERSPEC{L"Macros", L"*.js;*.vbs;*.ppa;*.py;*.mac"});
specs.push_back(COMDLG_FILTERSPEC{L"JScript", L"*.js"});
specs.push_back(COMDLG_FILTERSPEC{L"VBScript", L"*.vbs"});
specs.push_back(COMDLG_FILTERSPEC{L"Pascal", L"*.ppa"});
specs.push_back(COMDLG_FILTERSPEC{L"Python", L"*.py"});
specs.push_back(COMDLG_FILTERSPEC{L"Key Macro", L"*.mac"});
break;
case EFITER_NONE:
Expand Down
Loading

0 comments on commit 96bbe32

Please sign in to comment.