Add public paste CLI and skill

Provide a zero-dependency Python tool that races multiple public paste providers and documents safe AI-tool usage through a project skill.
This commit is contained in:
2026-05-12 13:14:05 +08:00
parent 8b9720a338
commit fbde4d6aca
13 changed files with 1035 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
from __future__ import annotations
import pytest
from publicpaste.validation import ValidationError, body_contains_text_fragment, validate_url
@pytest.mark.parametrize(
("provider", "url"),
[
("paste.rs", "https://paste.rs/abc123"),
("dpaste.org", "https://dpaste.org/ABC123"),
("0x0.st", "https://0x0.st/abcd.txt"),
("snippet.host", "https://snippet.host/abcdef"),
("paste.centos.org", "https://paste.centos.org/view/12345"),
("termbin.com", "http://termbin.com/abc"),
],
)
def test_validate_url_accepts_provider_urls(provider: str, url: str) -> None:
assert validate_url(provider, url) == url
@pytest.mark.parametrize(
("provider", "url"),
[
("paste.rs", "ftp://paste.rs/abc"),
("paste.rs", "https://example.com/abc"),
("0x0.st", "https://0x0.st/"),
("dpaste.org", "https://dpaste.org/a b"),
],
)
def test_validate_url_rejects_bad_urls(provider: str, url: str) -> None:
with pytest.raises(ValidationError):
validate_url(provider, url)
def test_body_contains_text_fragment_tolerates_html_escape() -> None:
assert body_contains_text_fragment(b"<pre>hello &amp; goodbye</pre>", "hello & goodbye")
def test_body_contains_text_fragment_rejects_missing_text() -> None:
assert not body_contains_text_fragment("something else", "hello world")