From 71abfaf13b03c4f10ff59c311349f7c9247baea7 Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Thu, 11 Mar 2010 16:04:08 +0000 Subject: [PATCH] If TEMPPATH pointed to unexisted, display message and doing nothing instead abort --- docs/notework.rus | 4 ++++ docs/notework.txt | 4 ++++ golded3/geedit2.cpp | 11 ++++++++++ golded3/geread2.cpp | 50 ++++++++++++++++++++++++++++++++------------- 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/docs/notework.rus b/docs/notework.rus index 70eec88..c2f14fa 100644 --- a/docs/notework.rus +++ b/docs/notework.rus @@ -10,6 +10,10 @@ _____________________________________________________________________________ Заметки для GoldED+ 1.1.5, /snapshot/ _____________________________________________________________________________ +! Если TEMPPATH указывает на несуществующий каталог, Golded+ показывает + сообщение и ничего не делает: при декодировании UUE, при импорте результата + команды, при вызове внешней утилиты. Ранее Golded+ аварийно завершался. + + Новая директива файла goldlang.cfg "IL_TMPINVALIDPATH" (сообщение "Invalid path for temporary files (TEMPPATH) - do nothing"). diff --git a/docs/notework.txt b/docs/notework.txt index 6c32d1e..47dbcac 100644 --- a/docs/notework.txt +++ b/docs/notework.txt @@ -10,6 +10,10 @@ ______________________________________________________________________ Notes for GoldED+ 1.1.5, /snapshot/ ______________________________________________________________________ +! If TEMPPATH is pointed to unexisted directory the Golded+ displays + message and does nothing on UU-decoding, on importing result of shell + command and on calling extern utility. Early Golded+ are aborted. + + New token IL_TMPINVALIDPATH for goldlang.cfg (message "Invalid path for temporary files (TEMPPATH) - do nothing"). diff --git a/golded3/geedit2.cpp b/golded3/geedit2.cpp index 17055f4..67864b5 100644 --- a/golded3/geedit2.cpp +++ b/golded3/geedit2.cpp @@ -946,6 +946,17 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) { if(filenamebuf.c_str()[0] == '|'){ Path cmdline; + if( not ((*CFG->temppath == NUL ) or is_dir(CFG->temppath)) ) + { + w_info(LNG->TMPinvalidpath); + SayBibi(); + waitkeyt(10000); + w_info(""); + AA->SetXlatimport(__oldxlatimport); + GFTRK(0); + return; + } + isPipe = YES; mktemp(strxcpy(tmpfile, AddPath(CFG->temppath, "GIXXXXXX"), sizeof(Path))); strxmerge(cmdline, sizeof(Path), filenamebuf.c_str()+1, " > ", tmpfile, NULL); diff --git a/golded3/geread2.cpp b/golded3/geread2.cpp index e26a4a5..02ef411 100644 --- a/golded3/geread2.cpp +++ b/golded3/geread2.cpp @@ -538,25 +538,38 @@ void TouchNetscan(int popup) int ExternUtil(GMsg *msg, const ExtUtil &extutil) { Path editorfile, tmpfile, buf; + std::string cmdline = extutil.cmdline; + int mode = (extutil.options & EXTUTIL_KEEPCTRL) ? MODE_SAVE : MODE_SAVENOCTRL; + + if(striinc("@tmpfile", cmdline.c_str())) + { + if( (*CFG->temppath == NUL ) or is_dir(CFG->temppath) ) + { + mktemp(strcpy(tmpfile, AddPath(CFG->temppath, "GDXXXXXX"))); + SaveLines(mode, tmpfile, msg, 79); + strcpy(buf, tmpfile); + strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); + strischg(cmdline, "@tmpfile", buf); + } + else + { + w_info(LNG->TMPinvalidpath); + SayBibi(); + waitkeyt(10000); + w_info(""); + return NO; + } + } + else + tmpfile[0] = NUL; + strxcpy(editorfile, AddPath(CFG->goldpath, EDIT->File()), sizeof(Path)); - std::string cmdline = extutil.cmdline; - - int mode = (extutil.options & EXTUTIL_KEEPCTRL) ? MODE_SAVE : MODE_SAVENOCTRL; SaveLines(mode, editorfile, msg, 79); strcpy(buf, editorfile); strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); strischg(cmdline, "@file", buf); - if(striinc("@tmpfile", cmdline.c_str())) - { - mktemp(strcpy(tmpfile, AddPath(CFG->temppath, "GDXXXXXX"))); - SaveLines(mode, tmpfile, msg, 79); - strcpy(buf, tmpfile); - strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); - strischg(cmdline, "@tmpfile", buf); - } - else - tmpfile[0] = NUL; + strcpy(buf, CFG->goldpath); strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); strischg(cmdline, "@path", buf); @@ -803,7 +816,7 @@ void ReadPeekURLs(GMsg* msg) std::string cmdline = it->handler.cmdline; std::string buf = "\"" + strtrim(strltrim(Listi[n])) + "\""; strischg(cmdline, "@url", buf.c_str()); - + buf = CFG->goldpath; strchg(buf, GOLD_WRONG_SLASH_CHR, GOLD_SLASH_CHR); strischg(cmdline, "@path", buf.c_str()); @@ -840,6 +853,15 @@ void UUDecode(GMsg* msg) { Path infile, outfile; bool ok = false; + if( not ((*CFG->temppath == NUL ) or is_dir(CFG->temppath)) ) + { + w_info(LNG->TMPinvalidpath); + SayBibi(); + waitkeyt(10000); + w_info(""); + return; + } + if((*CFG->uudecodepath == NUL) or is_dir(CFG->uudecodepath)) { mktemp(strcpy(infile, AddPath(CFG->temppath, "GDXXXXXX")));