Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line endings are converted to \r\n #249

Open
TehPeGaSuS opened this issue Mar 8, 2024 · 2 comments
Open

Line endings are converted to \r\n #249

TehPeGaSuS opened this issue Mar 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@TehPeGaSuS
Copy link

Ive uploaded a file (raw file here) to https://bpa.st/.

It's a Bash script and I even choose Bash from the programming language selector.

Since I've made it on Linux with nano it has LF as line ending.

But, when I do wget https://bpa.st/raw/6V5Q it is saved with CRLF as line endings like if it was made on Windows, which breaks the script entirely.

Example:

vitor@EliteDesk:~/Testing$ file userip.sh 
userip.sh: Bourne-Again shell script, ASCII text executable
vitor@EliteDesk:~/Testing$ wget https://bpa.st/raw/6V5Q
--2024-03-08 16:59:16--  https://bpa.st/raw/6V5Q
Resolving bpa.st (bpa.st)... 2a01:4f9:5a:5159::2, 65.109.61.99
Connecting to bpa.st (bpa.st)|2a01:4f9:5a:5159::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 490 [text/plain]
Saving to: ‘6V5Q’

6V5Q                                      100%[=====================================================================================>]     490  --.-KB/s    in 0s      

2024-03-08 16:59:16 (75,4 MB/s) - ‘6V5Q’ saved [490/490]

vitor@EliteDesk:~/Testing$ file 6V5Q 
6V5Q: ASCII text, with CRLF line terminators

If I try to run the script that I just wget'd:

vitor@EliteDesk:~/Testing$ bash 6V5Q 
6V5Q: line 1: !/usr/bin/env: No such file or directory

However, I've uploaded it to Debian pastebin (raw file here) and I use wget https://paste.debian.net/plain/1309920 it is saved with LF line endings.
Example:

vitor@EliteDesk:~/Testing$ wget https://paste.debian.net/plain/1309920
--2024-03-08 17:09:50--  https://paste.debian.net/plain/1309920
Resolving paste.debian.net (paste.debian.net)... 2a01:4f8:201:3437::2, 148.251.236.38
Connecting to paste.debian.net (paste.debian.net)|2a01:4f8:201:3437::2|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘1309920’

1309920                                       [ <=>                                                                                  ]     453  --.-KB/s    in 0s      

2024-03-08 17:09:50 (53,7 MB/s) - ‘1309920’ saved [453]

vitor@EliteDesk:~/Testing$ file 1309920 
1309920: Bourne-Again shell script, ASCII text executable

I assume that the issue comes from pinnwand itself?

@supakeen
Copy link
Owner

supakeen commented Mar 9, 2024

I would assume the same. It seems the data is already stored with CRLF line endings in the database as requesting the hex view shows the \0d\0a bytes directly.

As a quick sidenote, your initial paste will expire so I'll include all relevant URLs here (by the way, your shebang is missing a # on the bpa.st paste):

€ curl https://bpa.st/raw/6V5Q
!/usr/bin/env bash
read -r -p 'User Name: ' theUser
printf "Adding IPv6 address to netplan"
theIp=$(printf "%s$(echo -n "$theUser" | sha1sum | head -c 16 | sed 's/..../:&/g')\n" "200a:200b:200c:200d")
echo "        # $theUser" >> /etc/netplan/01-netcfg.yaml &&
echo "        - $theIp/64" >> /etc/netplan/01-netcfg.yaml &&
printf "Username: $theUser\nIP: $theIp\n" &&
cat /etc/netplan/01-netcfg.yaml | grep -A1 "$theUser" &&
/usr/sbin/netplan apply &&
sleep 2 &&
ping6 -c4 "$theIp"%
€ curl https://bpa.st/hex/6V5Q
212f7573722f62696e2f656e7620626173680d0a72656164202d72202d70202755736572204e616d653a202720746865557365720d0a7072696e74662022416464696e672049507636206164647265737320746f206e6574706c616e220d0a74686549703d24287072696e74662022257324286563686f202d6e2022247468655573657222207c207368613173756d207c2068656164202d63203136207c207365642027732f2e2e2e2e2f3a262f6727295c6e222022323030613a323030623a323030633a3230306422290d0a6563686f202220202020202020202320247468655573657222203e3e202f6574632f6e6574706c616e2f30312d6e65746366672e79616d6c2026260d0a6563686f202220202020202020202d202474686549702f363422203e3e202f6574632f6e6574706c616e2f30312d6e65746366672e79616d6c2026260d0a7072696e74662022557365726e616d653a2024746865557365725c6e49503a202474686549705c6e222026260d0a636174202f6574632f6e6574706c616e2f30312d6e65746366672e79616d6c207c2067726570202d413120222474686555736572222026260d0a2f7573722f7362696e2f6e6574706c616e206170706c792026260d0a736c65657020322026260d0a70696e6736202d6334202224746865497022% 
€ curl https://bpa.st/raw/6V5Q | hexdump -C
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   490  100   490    0     0   4591      0 --:--:-- --:--:-- --:--:--  4622
00000000  21 2f 75 73 72 2f 62 69  6e 2f 65 6e 76 20 62 61  |!/usr/bin/env ba|
00000010  73 68 0d 0a 72 65 61 64  20 2d 72 20 2d 70 20 27  |sh..read -r -p '|
00000020  55 73 65 72 20 4e 61 6d  65 3a 20 27 20 74 68 65  |User Name: ' the|
00000030  55 73 65 72 0d 0a 70 72  69 6e 74 66 20 22 41 64  |User..printf "Ad|
00000040  64 69 6e 67 20 49 50 76  36 20 61 64 64 72 65 73  |ding IPv6 addres|
00000050  73 20 74 6f 20 6e 65 74  70 6c 61 6e 22 0d 0a 74  |s to netplan"..t|
00000060  68 65 49 70 3d 24 28 70  72 69 6e 74 66 20 22 25  |heIp=$(printf "%|
00000070  73 24 28 65 63 68 6f 20  2d 6e 20 22 24 74 68 65  |s$(echo -n "$the|
00000080  55 73 65 72 22 20 7c 20  73 68 61 31 73 75 6d 20  |User" | sha1sum |
00000090  7c 20 68 65 61 64 20 2d  63 20 31 36 20 7c 20 73  || head -c 16 | s|
000000a0  65 64 20 27 73 2f 2e 2e  2e 2e 2f 3a 26 2f 67 27  |ed 's/..../:&/g'|
000000b0  29 5c 6e 22 20 22 32 30  30 61 3a 32 30 30 62 3a  |)\n" "200a:200b:|
000000c0  32 30 30 63 3a 32 30 30  64 22 29 0d 0a 65 63 68  |200c:200d")..ech|
000000d0  6f 20 22 20 20 20 20 20  20 20 20 23 20 24 74 68  |o "        # $th|
000000e0  65 55 73 65 72 22 20 3e  3e 20 2f 65 74 63 2f 6e  |eUser" >> /etc/n|
000000f0  65 74 70 6c 61 6e 2f 30  31 2d 6e 65 74 63 66 67  |etplan/01-netcfg|
00000100  2e 79 61 6d 6c 20 26 26  0d 0a 65 63 68 6f 20 22  |.yaml &&..echo "|
00000110  20 20 20 20 20 20 20 20  2d 20 24 74 68 65 49 70  |        - $theIp|
00000120  2f 36 34 22 20 3e 3e 20  2f 65 74 63 2f 6e 65 74  |/64" >> /etc/net|
00000130  70 6c 61 6e 2f 30 31 2d  6e 65 74 63 66 67 2e 79  |plan/01-netcfg.y|
00000140  61 6d 6c 20 26 26 0d 0a  70 72 69 6e 74 66 20 22  |aml &&..printf "|
00000150  55 73 65 72 6e 61 6d 65  3a 20 24 74 68 65 55 73  |Username: $theUs|
00000160  65 72 5c 6e 49 50 3a 20  24 74 68 65 49 70 5c 6e  |er\nIP: $theIp\n|
00000170  22 20 26 26 0d 0a 63 61  74 20 2f 65 74 63 2f 6e  |" &&..cat /etc/n|
00000180  65 74 70 6c 61 6e 2f 30  31 2d 6e 65 74 63 66 67  |etplan/01-netcfg|
00000190  2e 79 61 6d 6c 20 7c 20  67 72 65 70 20 2d 41 31  |.yaml | grep -A1|
000001a0  20 22 24 74 68 65 55 73  65 72 22 20 26 26 0d 0a  | "$theUser" &&..|
000001b0  2f 75 73 72 2f 73 62 69  6e 2f 6e 65 74 70 6c 61  |/usr/sbin/netpla|
000001c0  6e 20 61 70 70 6c 79 20  26 26 0d 0a 73 6c 65 65  |n apply &&..slee|
000001d0  70 20 32 20 26 26 0d 0a  70 69 6e 67 36 20 2d 63  |p 2 &&..ping6 -c|
000001e0  34 20 22 24 74 68 65 49  70 22                    |4 "$theIp"|
000001ea
€ curl https://paste.debian.net/plain/1309920 | hexdump -C
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   453    0   453    0     0   1163      0 --:--:-- --:--:-- --:--:--  1164
00000000  23 21 2f 75 73 72 2f 62  69 6e 2f 65 6e 76 20 62  |#!/usr/bin/env b|
00000010  61 73 68 0a 72 65 61 64  20 2d 72 20 2d 70 20 27  |ash.read -r -p '|
00000020  55 73 65 72 20 4e 61 6d  65 3a 20 27 20 74 68 65  |User Name: ' the|
00000030  55 73 65 72 0a 70 72 69  6e 74 66 20 22 5c 6e 5c  |User.printf "\n\|
00000040  6e 22 0a 74 68 65 49 70  3d 24 28 70 72 69 6e 74  |n".theIp=$(print|
00000050  66 20 22 25 73 24 28 65  63 68 6f 20 2d 6e 20 22  |f "%s$(echo -n "|
00000060  24 74 68 65 55 73 65 72  22 20 7c 20 73 68 61 31  |$theUser" | sha1|
00000070  73 75 6d 20 7c 20 68 65  61 64 20 2d 63 20 31 36  |sum | head -c 16|
00000080  20 7c 20 73 65 64 20 27  73 2f 2e 2e 2e 2e 2f 3a  | | sed 's/..../:|
00000090  26 2f 67 27 29 5c 6e 22  20 22 32 61 30 31 3a 34  |&/g')\n" "2a01:4|
000000a0  66 38 3a 32 36 31 3a 34  64 63 34 22 29 0a 65 63  |f8:261:4dc4").ec|
000000b0  68 6f 20 22 20 20 20 20  20 20 20 20 23 20 24 74  |ho "        # $t|
000000c0  68 65 55 73 65 72 22 20  3e 3e 20 2f 65 74 63 2f  |heUser" >> /etc/|
000000d0  6e 65 74 70 6c 61 6e 2f  30 31 2d 6e 65 74 63 66  |netplan/01-netcf|
000000e0  67 2e 79 61 6d 6c 20 26  26 0a 65 63 68 6f 20 22  |g.yaml &&.echo "|
000000f0  20 20 20 20 20 20 20 20  2d 20 24 74 68 65 49 70  |        - $theIp|
00000100  2f 36 34 22 20 3e 3e 20  2f 65 74 63 2f 6e 65 74  |/64" >> /etc/net|
00000110  70 6c 61 6e 2f 30 31 2d  6e 65 74 63 66 67 2e 79  |plan/01-netcfg.y|
00000120  61 6d 6c 20 26 26 0a 70  72 69 6e 74 66 20 22 55  |aml &&.printf "U|
00000130  73 65 72 6e 61 6d 65 3a  20 24 74 68 65 55 73 65  |sername: $theUse|
00000140  72 5c 6e 49 50 3a 20 24  74 68 65 49 70 5c 6e 22  |r\nIP: $theIp\n"|
00000150  20 26 26 0a 63 61 74 20  2f 65 74 63 2f 6e 65 74  | &&.cat /etc/net|
00000160  70 6c 61 6e 2f 30 31 2d  6e 65 74 63 66 67 2e 79  |plan/01-netcfg.y|
00000170  61 6d 6c 20 7c 20 67 72  65 70 20 2d 41 31 20 22  |aml | grep -A1 "|
00000180  24 74 68 65 55 73 65 72  22 20 26 26 0a 2f 75 73  |$theUser" &&./us|
00000190  72 2f 73 62 69 6e 2f 6e  65 74 70 6c 61 6e 20 61  |r/sbin/netplan a|
000001a0  70 70 6c 79 20 26 26 0a  73 6c 65 65 70 20 32 20  |pply &&.sleep 2 |
000001b0  26 26 0a 70 69 6e 67 36  20 2d 63 34 20 22 24 74  |&&.ping6 -c4 "$t|
000001c0  68 65 49 70 22                                    |heIp"|
000001c5

@supakeen supakeen added the bug Something isn't working label Mar 9, 2024
@supakeen supakeen changed the title File conversion? Line endings are converted to \r\n Mar 9, 2024
@TehPeGaSuS
Copy link
Author

As a quick sidenote, your initial paste will expire so I'll include all relevant URLs here (by the way, your shebang is missing a # on the bpa.st paste)

Yeah, I've probably mispasted it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants