Skip to content

Commit df81a2c

Browse files
committed
Fix log messages containing a path
Escape backslash characters in the windows paths, to prevent them from being interpreted as special character identifiers in printf functions Fixes for issue automaticanalysis#276
1 parent 78577e2 commit df81a2c

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

‎aa_engine/aa_doprocessing.m‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,9 @@
283283
msg='';
284284
alldone=true;
285285
doneflag=aas_doneflag_getpath_bydomain(aap,domain,indices,k);
286-
286+
% When used in aas_log messages, escape backward slashes from windows paths.
287+
logsafe_path = strrep(doneflag, '\', '\\');
288+
287289
% Check whether tasksettings have changed since the last execution,
288290
% and if they have, then delete doneflag to trigger re-execution
289291
if strcmp(task,'doit') && isfield(aap.options,'checktasksettingconsistency') && aap.options.checktasksettingconsistency && aas_doneflagexists(aap,doneflag)
@@ -297,7 +299,7 @@
297299
end
298300

299301
if aas_doneflagexists(aap,doneflag) && strcmp(task,'doit')
300-
msg=[msg sprintf('- done: %s for %s \n',description,doneflag)];
302+
msg=[msg sprintf('- done: %s for %s \n',description,logsafe_path)];
301303
else
302304
alldone=false;
303305
switch (task)
@@ -329,7 +331,7 @@
329331
taskmask.tobecompletedfirst=tbcf;
330332

331333
% now queue current stage
332-
aas_log(aap,0,sprintf('MODULE %s PENDING: %s for %s',stagename,description,doneflag));
334+
aas_log(aap,0,sprintf('MODULE %s PENDING: %s for %s',stagename,description,logsafe_path));
333335

334336
taskmask.indices=indices;
335337
taskmask.doneflag=doneflag;

‎aa_engine/aa_doprocessing_onetask.m‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363

6464
% Now execute the module, and change the 'done' flags if task='doit'
6565

66-
[doneflag doneflagpath stagetag]=aas_doneflag_getpath_bydomain(aap,domain,indices,modulenum);
66+
[doneflag, doneflagpath, stagetag]=aas_doneflag_getpath_bydomain(aap,domain,indices,modulenum);
67+
% When used in aas_log messages, escape backward slashes from windows paths.
68+
logsafe_path = strrep(doneflagpath, '\', '\\');
6769
outputpath=aas_getpath_bydomain(aap,domain,indices);
6870
aas_makedir(aap,outputpath);
6971
aap_tmp=aap;
@@ -72,7 +74,7 @@
7274
aap=aap_tmp;
7375
if (aas_doneflagexists(aap,doneflag))
7476
if (strcmp(task,'doit'))
75-
aas_log(aap,0,sprintf('- completed previously: %s for %s',description,doneflagpath),aap.gui_controls.colours.completedpreviously);
77+
aas_log(aap,0,sprintf('- completed previously: %s for %s',description,logsafe_path),aap.gui_controls.colours.completedpreviously);
7678
% re-write done flag as it clears dependencies
7779
aas_writedoneflag(aap,doneflag);
7880
end
@@ -92,7 +94,7 @@
9294
aas_delete_doneflag_bydomain(aap,aap.internal.outputstreamdestinations{modulenum}.stream(k0i).destnumber,domain,indices);
9395
end
9496
% now run current stage
95-
aas_log(aap,0,sprintf('MODULE %s RUNNING: %s for %s',stagename,description,doneflagpath),aap.gui_controls.colours.running);
97+
aas_log(aap,0,sprintf('MODULE %s RUNNING: %s for %s',stagename,description,logsafe_path),aap.gui_controls.colours.running);
9698

9799
% ...fetch inputs
98100
if ~isempty(aap.internal.inputstreamsources{modulenum})

‎aa_engine/aas_checkpath.m‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
passed=true;
3434
else
3535
passed=false;
36-
aas_log(aap,true,sprintf('Paths in aa can only contain the characters a-z, A-Z, 0-9, _, -, ., / and sometimes wildcards/colons \nYour path %s=''%s'' does not satisfy this.',nme,pth));
37-
end;
36+
% When used in aas_log messages, escape backward slashes from windows paths.
37+
logsafe_path = strrep(pth, '\', '\\');
38+
aas_log(aap,true,sprintf('Paths in aa can only contain the characters a-z, A-Z, 0-9, _, -, ., / and sometimes wildcards/colons \nYour path %s=''%s'' does not satisfy this.',nme,logsafe_path));
39+
end
3840
end

0 commit comments

Comments
 (0)