janlelis/clipboard

Cannot copy 8192 bytes of data with xsel

Closed this issue · 0 comments

  • OS: Ubuntu Desktop 18.04 LTS (amd64)
  • xsel version 1.2.0
  • xclip not installed
  • Ruby 2.5.1p57
  • clipboard 1.1.2

Reproduce steps

Run the following script. This script will generate random data, copy it to the clipboard, and read it back for verification.

#!/usr/bin/env ruby
# encoding: utf-8

require "clipboard"

random = Random.new

Clipboard.clear()

(0..18).each{|power|
  data1 = random.bytes(2**power).unpack("H*").first
  $stdout.puts "Testing #{data1.bytesize} bytes"

  Clipboard.copy(data1)

  data2 = Clipboard.paste

  if data1 != data2 
    $stdout.puts "Test failed"

    $stdout.puts "Copy:  #{data1.bytesize} bytes"
    $stdout.puts "Paste: #{data2.bytesize} bytes"
    exit 1
  end
}

Expected result

Testing 2 bytes
Testing 4 bytes
Testing 8 bytes
Testing 16 bytes
Testing 32 bytes
Testing 64 bytes
Testing 128 bytes
Testing 256 bytes
Testing 512 bytes
Testing 1024 bytes
Testing 2048 bytes
Testing 4096 bytes
Testing 8192 bytes
Testing 16384 bytes
Testing 32768 bytes
Testing 65536 bytes
Testing 131072 bytes
Testing 262144 bytes
Testing 524288 bytes

Actual result

Testing 2 bytes
Testing 4 bytes
Testing 8 bytes
Testing 16 bytes
Testing 32 bytes
Testing 64 bytes
Testing 128 bytes
Testing 256 bytes
Testing 512 bytes
Testing 1024 bytes
Testing 2048 bytes
Testing 4096 bytes
Testing 8192 bytes
Test failed
Copy:  8192 bytes
Paste: 4096 bytes

Additional information

Platform with xclip installed will not be affected by this issue. However, it seems that xclip cannot copy more than 1 MiB of data (1048576 bytes)