Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Sanitize BuildCommand.output by removing NULL characters #4552
PostgreSQL doesn't support NULL (\x00) characters on TextFields.
Django 2.0 introduces a new validator that doesn't allow NULL characters to reach the database:
This commit just replaces the NULL characters of the stdout and stder from the command ran by '' (empty string) to avoid conflicts when saving them into the database.
I didn't find an easy way to test this.
I wrote a test like this
def test_null_output(self): """Include NULL (\x00) characters on command output.""" cmd = BuildCommand(['/bin/bash', '-c', 'echo -n H\0i']) cmd.run() self.assertEqual(cmd.output, 'Hi')
but it fails with an exception like