HomePhorge

(PUP-1389) Embed the extra NULL within the string
cabd95cbd06aUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(PUP-1389) Embed the extra NULL within the string

Previously, we were appending a NULL to the wide encoded string to work around
a ruby bug fixed in 2.1.

However, we were calling String#strip, which makes a copy of the string, and
in the process only preserves the first NULL.

This commit embeds a NULL within the string itself, e.g. "bob\0". Since the
NULL is part of the string data, ruby will preserve it.

Also, String#+ cannot combine strings with different encodings,
e.g. "a".encode('UTF-16LE') + "\0" results in:

incompatible character encodings: UTF-16LE and US-ASCII

which is why we need to encode the terminator. The actual message depends on
the default encoding, e.g. US-ASCII, UTF-8.

Details

Provenance
Josh Cooper <josh@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU42d4dff67994: Merge branch 'pr/2261' into stable
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Cooper <josh@puppetlabs.com> committed rPUcabd95cbd06a: (PUP-1389) Embed the extra NULL within the string (authored by Josh Cooper <josh@puppetlabs.com>).Jan 17 2014, 7:35 PM