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

raw html in terminal when user-agent is set #407

Open
inokawazu opened this issue Apr 19, 2024 · 0 comments
Open

raw html in terminal when user-agent is set #407

inokawazu opened this issue Apr 19, 2024 · 0 comments

Comments

@inokawazu
Copy link

Bug: When the user-agent is set the output to terminal is raw html.

I ran into this issue because the the user-agent was set in my curlrc.

Suggested fix 1: Use mime type like text/plain or application/text to detect terminal users.
Suggested fix 2: Use text/html mime type to detect browser users and default otherwise to text.

Reproducible Example

input

curl -H 'user-agent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"' cht.sh/:styles-demo

output (truncated)

<html>
<head><title>cheat.sh/:styles-demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="search" type="application/opensearchdescription+xml" href="/files/opensearch.xml" title="cheat.sh" />
<link rel="stylesheet" type="text/css" href="/files/style.css" />
<style type="text/css">
.ef0,.f0 { color: #073642; } .eb0,.b0 { background-color: #073642; }
.ef1,.f1 { color: #D30102; } .eb1,.b1 { background-color: #D30102; }
.ef2,.f2 { color: #859900; } .eb2,.b2 { background-color: #859900; }
.ef3,.f3 { color: #B58900; } .eb3,.b3 { background-color: #B58900; }
...
<a href="https://twitter.com/igor_chubin" class="twitter-follow-button" data-show-count="false" data-button="grey">Follow @igor_chubin</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

<!-- Place this tag where you want the button to render. -->
<a aria-label="Star chubin/wttr.in on GitHub" data-count-aria-label="# stargazers on GitHub" data-count-api="/repos/chubin/cheat.sh#stargazers_count" data-count-href="/chubin/cheat.sh/stargazers" data-icon="octicon-star" href="https://github.com/chubin/cheat.sh" class="github-button">cheat.sh</a>

<!-- Place this tag right after the last button or just before your close body tag. -->
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant