mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Obfuscation: rc.obfuscate=1 hides private details
This commit is contained in:
parent
c34b2b8cfb
commit
5d60f426a8
5 changed files with 45 additions and 0 deletions
|
@ -342,6 +342,7 @@ std::string Config::_defaults =
|
|||
"list.all.tags=no # Include old tag names in 'tags' command\n"
|
||||
"print.empty.columns=no # Print columns which have no data for any task\n"
|
||||
"debug=no # Display diagnostics\n"
|
||||
"obfuscate=no # Obfuscate data for error reporting\n"
|
||||
"fontunderline=yes # Uses underlines rather than -------\n"
|
||||
"shell.prompt=task> # Prompt used by the shell command\n"
|
||||
"\n"
|
||||
|
|
|
@ -114,6 +114,7 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
{
|
||||
context.timer_render.start ();
|
||||
|
||||
bool const obfuscate = context.config.getBoolean ("obfuscate");
|
||||
bool const print_empty_columns = context.config.getBoolean ("print.empty.columns");
|
||||
std::vector <Column*> nonempty_columns;
|
||||
std::vector <bool> nonempty_sort;
|
||||
|
@ -321,6 +322,10 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
|
|||
|
||||
if (cells[c].size () > max_lines)
|
||||
max_lines = cells[c].size ();
|
||||
|
||||
if (obfuscate)
|
||||
for (unsigned int line = 0; line < cells[c].size (); ++line)
|
||||
cells[c][line] = obfuscateText (cells[c][line]);
|
||||
}
|
||||
|
||||
// Listing breaks are simply blank lines inserted when a column value
|
||||
|
|
|
@ -114,6 +114,8 @@ void ViewText::set (int row, int col, Color color)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string ViewText::render ()
|
||||
{
|
||||
bool const obfuscate = context.config.getBoolean ("obfuscate");
|
||||
|
||||
// Determine minimal, ideal column widths.
|
||||
std::vector <int> minimal;
|
||||
std::vector <int> ideal;
|
||||
|
@ -265,6 +267,10 @@ std::string ViewText::render ()
|
|||
|
||||
if (cells[col].size () > max_lines)
|
||||
max_lines = cells[col].size ();
|
||||
|
||||
if (obfuscate)
|
||||
for (unsigned int line = 0; line < cells[col].size (); ++line)
|
||||
cells[col][line] = obfuscateText (cells[col][line]);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < max_lines; ++i)
|
||||
|
|
32
src/text.cpp
32
src/text.cpp
|
@ -624,6 +624,38 @@ int strippedLength (const std::string& input)
|
|||
return count;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string obfuscateText (const std::string& input)
|
||||
{
|
||||
std::stringstream output;
|
||||
std::string::size_type i = 0;
|
||||
int character;
|
||||
bool inside = false;
|
||||
|
||||
while ((character = utf8_next_char (input, i)))
|
||||
{
|
||||
if (inside)
|
||||
{
|
||||
output << (char) character;
|
||||
|
||||
if (character == 'm')
|
||||
inside = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (character == 033)
|
||||
inside = true;
|
||||
|
||||
if (inside || character == ' ')
|
||||
output << (char) character;
|
||||
else
|
||||
output << 'x';
|
||||
}
|
||||
}
|
||||
|
||||
return output.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
const std::string format (char value)
|
||||
{
|
||||
|
|
|
@ -55,6 +55,7 @@ bool closeEnough (const std::string&, const std::string&, unsigned int minLength
|
|||
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
||||
std::string::size_type find (const std::string&, const std::string&, std::string::size_type, bool sensitive = true);
|
||||
int strippedLength (const std::string&);
|
||||
const std::string obfuscateText (const std::string&);
|
||||
const std::string format (char);
|
||||
const std::string format (int);
|
||||
const std::string formatHex (int);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue