mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-26 14:29:08 +01:00
Bound the Windows clipboard read by the block size instead of scanning for a NUL
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
//go:build windows
|
||||
|
||||
package server
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// Clipboard text is set by whichever local process owns the clipboard, and
|
||||
// nothing makes it end in a NUL. Decoding must stop at the block's end, not
|
||||
// run on looking for a terminator.
|
||||
func TestUTF16UpToNUL(t *testing.T) {
|
||||
assert.Equal(t, "hi", utf16UpToNUL([]uint16{'h', 'i', 0, 'x'}), "stops at the first NUL")
|
||||
assert.Equal(t, "hi", utf16UpToNUL([]uint16{'h', 'i'}), "an unterminated block decodes to its end and no further")
|
||||
assert.Equal(t, "", utf16UpToNUL([]uint16{0, 'x'}), "a leading NUL is an empty string")
|
||||
assert.Equal(t, "", utf16UpToNUL(nil))
|
||||
}
|
||||
Reference in New Issue
Block a user