Skip to content
Snippets Groups Projects
Commit 3d8fa2e9 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add an optional bool argument to sbbs_t::editfile() and JS console.edit_file()

... to not clean (remove) an existing quotes file (which is removed for
for security/privacy reasons).

This fixes issue #710 for Nightfox, but he'll need to deal with the security
issue in that case.
parent e923cd3d
No related branches found
No related tags found
No related merge requests found
Pipeline #5494 passed
...@@ -1616,6 +1616,7 @@ js_editfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1616,6 +1616,7 @@ js_editfile(JSContext *cx, uintN argc, jsval *arglist)
char* subj{nullptr}; char* subj{nullptr};
char* msgarea{nullptr}; char* msgarea{nullptr};
int32 maxlines = 10000; int32 maxlines = 10000;
bool clean_quotes = true;
jsrefcount rc; jsrefcount rc;
JSBool result = JS_TRUE; JSBool result = JS_TRUE;
...@@ -1654,6 +1655,8 @@ js_editfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1654,6 +1655,8 @@ js_editfile(JSContext *cx, uintN argc, jsval *arglist)
} }
continue; continue;
} }
if(JSVAL_IS_BOOLEAN(argv[i]))
clean_quotes = JSVAL_TO_BOOLEAN(argv[i]);
} }
if(path == nullptr) { if(path == nullptr) {
...@@ -1662,7 +1665,7 @@ js_editfile(JSContext *cx, uintN argc, jsval *arglist) ...@@ -1662,7 +1665,7 @@ js_editfile(JSContext *cx, uintN argc, jsval *arglist)
} }
if (result == JS_TRUE) { if (result == JS_TRUE) {
rc=JS_SUSPENDREQUEST(cx); rc=JS_SUSPENDREQUEST(cx);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->editfile(path, maxlines, to, from, subj, msgarea))); JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(sbbs->editfile(path, maxlines, to, from, subj, msgarea, clean_quotes)));
JS_RESUMEREQUEST(cx, rc); JS_RESUMEREQUEST(cx, rc);
} }
free(path); free(path);
...@@ -2641,7 +2644,7 @@ static jsSyncMethodSpec js_console_functions[] = { ...@@ -2641,7 +2644,7 @@ static jsSyncMethodSpec js_console_functions[] = {
,JSDOCSTR("Print the last <i>n</i> lines of file with optional print mode, original column width, and scope.") ,JSDOCSTR("Print the last <i>n</i> lines of file with optional print mode, original column width, and scope.")
,310 ,310
}, },
{"editfile", js_editfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,<i>number</i> maxlines=10000] [,<i>string</i> to] [,<i>string</i> from] [,<i>string</i> subject] [,<i>string</i> msg_area]") {"editfile", js_editfile, 1, JSTYPE_BOOLEAN, JSDOCSTR("filename [,<i>number</i> maxlines=10000] [,<i>string</i> to] [,<i>string</i> from] [,<i>string</i> subject] [,<i>string</i> msg_area] [,<i>bool</i> clean_quotes=true")
,JSDOCSTR("Edit/create a text file using the user's preferred message editor with optional override values for the drop file created to communicate metadata to an external editor") ,JSDOCSTR("Edit/create a text file using the user's preferred message editor with optional override values for the drop file created to communicate metadata to an external editor")
,310 ,310
}, },
......
...@@ -798,7 +798,7 @@ public: ...@@ -798,7 +798,7 @@ public:
bool forwardmsg(smb_t*, smbmsg_t*, const char* to, const char* subject = NULL, const char* comment = NULL); bool forwardmsg(smb_t*, smbmsg_t*, const char* to, const char* subject = NULL, const char* comment = NULL);
void removeline(char *str, char *str2, char num, char skip); void removeline(char *str, char *str2, char num, char skip);
uint msgeditor(char *buf, const char *top, char *title, uint max_lines, uint max_line_len); uint msgeditor(char *buf, const char *top, char *title, uint max_lines, uint max_line_len);
bool editfile(char *path, uint max_lines = 10000, const char* to = NULL, const char* from = NULL, const char* subj = NULL, const char* msgarea = NULL); bool editfile(char *path, uint max_lines = 10000, const char* to = NULL, const char* from = NULL, const char* subj = NULL, const char* msgarea = NULL, bool clean_quotes = true);
ushort chmsgattr(const smbmsg_t*); ushort chmsgattr(const smbmsg_t*);
bool quotemsg(smb_t*, smbmsg_t*, bool tails = false); bool quotemsg(smb_t*, smbmsg_t*, bool tails = false);
bool editmsg(smb_t*, smbmsg_t*); bool editmsg(smb_t*, smbmsg_t*);
......
...@@ -1238,7 +1238,7 @@ uint sbbs_t::msgeditor(char *buf, const char *top, char *title, uint maxlines, u ...@@ -1238,7 +1238,7 @@ uint sbbs_t::msgeditor(char *buf, const char *top, char *title, uint maxlines, u
/****************************************************************************/ /****************************************************************************/
/* Edits an existing file or creates a new one in MSG format */ /* Edits an existing file or creates a new one in MSG format */
/****************************************************************************/ /****************************************************************************/
bool sbbs_t::editfile(char *fname, uint maxlines, const char* to, const char* from, const char* subj, const char* msgarea) bool sbbs_t::editfile(char *fname, uint maxlines, const char* to, const char* from, const char* subj, const char* msgarea, bool clean_quotes)
{ {
char *buf,path[MAX_PATH+1]; char *buf,path[MAX_PATH+1];
char msgtmp[MAX_PATH+1]; char msgtmp[MAX_PATH+1];
...@@ -1257,8 +1257,8 @@ bool sbbs_t::editfile(char *fname, uint maxlines, const char* to, const char* fr ...@@ -1257,8 +1257,8 @@ bool sbbs_t::editfile(char *fname, uint maxlines, const char* to, const char* fr
if(useron_xedit && !chk_ar(cfg.xedit[useron_xedit-1]->ar, &useron, &client)) if(useron_xedit && !chk_ar(cfg.xedit[useron_xedit-1]->ar, &useron, &client))
useron_xedit = 0; useron_xedit = 0;
quotes_fname(useron_xedit, path, sizeof(path)); if(clean_quotes)
(void)removecase(path); (void)removecase(quotes_fname(useron_xedit, path, sizeof(path)));
if(to == NULL) if(to == NULL)
to = fname; to = fname;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment