You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On windows, paths can have a \ in them. However, aas_log uses printf functions during logging, with the input message as format specifier. In printf functions, a \ is the start of a special operator. Thus each time such a character is encountered, the printf function will either say that it does not recognize the operator, or print a message with unexpected formatting (i.e. it may have returned to the start of the line halfway into the message)
To prevent this, when a path is part of the message to aas_log, any \ characters should be escaped by doubling them, before sending the message to aas_log.
The replacement cannot be done inside aas_log on the incoming message, as some messages do use valid print formatting, e.g. they use \n to have a newline in the message.
% When used in aas_log messages, escape backward slashes from
% windows paths.
logsafe_path = strrep(unsafe_path, '\', '\\');
msg = sprintf('Done: %s for %s \n', description, logsafe_path);
aas_log(aap, false, msg)
The text was updated successfully, but these errors were encountered:
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
Escape backslash characters in the windows paths, to prevent them from being
interpreted as special character identifiers in printf functions
Partial fix for issue automaticanalysis#276
AljenU
added a commit
to AljenU/automaticanalysis
that referenced
this issue
Dec 16, 2021
Escape backslash characters in possible windows paths, to prevent them from being
interpreted as special character identifiers in printf functions
Partial fix for issue automaticanalysis#276
On windows, paths can have a \ in them. However, aas_log uses printf functions during logging, with the input message as format specifier. In printf functions, a \ is the start of a special operator. Thus each time such a character is encountered, the printf function will either say that it does not recognize the operator, or print a message with unexpected formatting (i.e. it may have returned to the start of the line halfway into the message)
To prevent this, when a path is part of the message to aas_log, any \ characters should be escaped by doubling them, before sending the message to aas_log.
The replacement cannot be done inside aas_log on the incoming message, as some messages do use valid print formatting, e.g. they use \n to have a newline in the message.
Example fix:
Old situation
Replace with:
The text was updated successfully, but these errors were encountered: