Github eats blank lines if copy and paste from code view

Hi,

I have an interesting problem for which I wanted to open an issue but couldn’t find the issue tracker for github.com, so here I am.

In short this is the problem:

I have a shell script in a github repo, which contains a package signing key in the pem format. It looks like this:

function write_rpm_key
{
cat << EOT >> /tmp/mykey.pub
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: rpm-4.11.3 (NSS-3)

DqVH6sm+eo1S2lydVPk/HcvSF5EwyVNWroawF531Em1bHEaanoC2FwLu5AAPEzVD
DqVH6sm+eo1S2lydVPk/HcvSF5EwyVNWroawF531Em1bHEaanoC2FwLu5AAPEzVD
DqVH6sm+eo1S2lydVPk/HcvSF5EwyVNWroawF531Em1bHEaanoC2FwLu5AAPEzVD
DqVH6sm+eo1S2lydVPk/HcvSF5EwyVNWroawF531Em1bHEaanoC2FwLu5AAPEzVD
DqVH6sm+eo1S2lydVPk/HcvSF5EwyVNWroawF531Em1bHEaanoC2FwLu5AAPEzVD
DqVH6sm+eo1S2lydVPk/HcvSF5EwyVNWroawF531Em1bHEaanoC2FwLu5AAPEzVD
AqvkiI/vIj00Iyoks2cANw==
=xIn/
-----END PGP PUBLIC KEY BLOCK-----
EOT
rpm --import /tmp/mykey.pub
rm -f /tmp/mykey.pub
}

Now, when I copy and paste that code from the code view something “eats” the blank lines. Thats typically not an issue, but in this case the key gets invalid, because a blank line is expected between the "Version: " Line and the actual base64 key. If I copy from the raw view - everything works as expected.

I know there are workarounds, but I do think that if as a user I copy something I get an exact copy and not something similar.

Steps to reproduce:

  1. open this link: copy_past_bug/testfile.sh at main · nikothome/copy_past_bug · GitHub
  2. mark the code from line 1 to 19
  3. press ctrl+c
  4. open local editor of your choice
  5. press ctrl-v

You’ll end up with 18 lines instead of 19 and line 6 is entirely missing.

kind regards,

Niko