mkaczanowski / pastebin

Simple, fast, standalone pastebin service
MIT License
155 stars 27 forks source link

It ignores '\n' so pastes look like one long line if GUI is not used #14

Closed t0nik0 closed 3 years ago

t0nik0 commented 3 years ago

or just cut the text if '\r' has been used:

$ echo -e 'Hello\nworld' | curl -w'\n' -q -L -d @- -o - http://localhost:8000/pb
http://localhost:8000/pb/raw/esBMfvlMqPdS9q93w0UWa
$ curl http://localhost:8000/pb/raw/esBMfvlMqPdS9q93w0UWa
Helloworld$
$ echo -e 'Hello\n\rworld' | curl -w'\n' -q -L -d @- -o - http://localhost:8000/pb
http://localhost:8000/pb/raw/3BbQLjwfYQAujQemn57Jg
$ curl http://localhost:8000/pb/raw/3BbQLjwfYQAujQemn57Jg
Hello$
$ echo -e 'Hello\n\nworld' | curl -w'\n' -q -L -d @- -o - http://localhost:8000/pb
http://localhost:8000/pb/raw/CrnsJ2ShoZCkUS5bnW491
$ curl http://localhost:8000/pb/raw/CrnsJ2ShoZCkUS5bnW491
Helloworld$
$ echo -e 'Hello\n\n\nworld' | curl -w'\n' -q -L -d @- -o - http://localhost:8000/pb
http://localhost:8000/pb/raw/N13YK6Jq-BkNxWrEJ0I5i
$ curl http://localhost:8000/pb/raw/N13YK6Jq-BkNxWrEJ0I5i
Helloworld$
mkaczanowski commented 3 years ago

The problem you described is not a fault of the pastebin itself but the way cURL works.

This creates the multiline output which curl handles as "Helloworld" and passes it in that form to pastebin service:

$ echo -e 'Hello\nworld'
Hello
world

If for instance, you decide to use httpie (https://httpie.io/):

$ echo -e 'Hello\nworld' | http -p b http://localhost:8000
http://localhost:8000/XOzLQ9ehSiMz-OZmCSPyp

$ curl "http://localhost:8000/raw/WLoItLb9Zqllwr9nj3uFR"
Hello
world

then the multiline gets converted to "Hello\nworld\n" and shipped to pastebin service