Skip to content

Commit

Permalink
Fixed the build failure caused by the breaking change in cookie <= 0.…
Browse files Browse the repository at this point in the history
…18 and changed the README format from .rst to .md (#9)

* Change the README format from .rst to .md to provider better crates.io support

* Fixed the code for cookie=0.18

* Fixed the README.md
  • Loading branch information
JohnScience authored Dec 11, 2023
1 parent 7e79c08 commit 82367df
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 83 deletions.
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
[package]
name = "browsercookie-rs"
version = "0.2.0"
authors = ["Bharadwaj Machiraju <tunnelshade.in>", "Piotr Czajka <piotr.filip.czajka@gmail.com"]
version = "0.2.1"
authors = [
"Bharadwaj Machiraju <tunnelshade.in>",
"Piotr Czajka <piotr.filip.czajka@gmail.com",
]
edition = "2018"
repository = "https://github.com/ginkooo/browsercookie-rs"
documentation = "https://docs.rs/browsercookie-rs/"
exclude = ["tests/resources/*"]
description = "A simple filesystem browser cookie extractor"
readme = "README.rst"
readme = "README.md"
license = "MIT"
keywords = ["cookies", "browser", "cli"]
categories = ["command-line-utilities"]
Expand All @@ -23,12 +26,12 @@ doc = false

[dependencies]
byteorder = "1"
cookie = "0"
cookie = "0.18"
dirs = "1"
lz4 = "1"
memmap = "0"
rust-ini = "0"
serde = { version = "1", features = ["derive"]}
serde = { version = "1", features = ["derive"] }
serde_json = "1"
regex = "1"
clap = "2"
Expand Down
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

# browsercookie-rs

A rust crate useful for extracting cookies from browsers. Inspired from [browsercookie](https://pypi.org/project/browsercookie/) python library.

## Library

### Usage

Using the library is quite simple

```rust
// Cargo.toml
[dependencies]
browsercookie-rs = { git="https://github.com/Ginkooo/browsercookie-rs.git", branch="main" }
```

```rust
use browsercookie::{CookieFinder, Browser, Attribute};
use regex::Regex;

let mut cookie_jar = CookieFinder::builder()
.with_regexp(Regex::new("google.com").unwrap(), Attribute::Domain)
.with_browser(Browser::Firefox)
.build()
.find()
.await;

let cookie = cookie_jar.get("some_cookie_name").unwrap();

println!("Cookie header string: Cookie: {}", cookie);
```

You can omit the `.with_` calls to get all cookies from all browsers.

A better example should be present in [browsercookies](src/bin.rs).

## Binary

The same crate should also give you a binary `browsercookies`, which should be usable from your favorite shell for crudely using frontend APIs for simple tooling.

```console
browsercookies --domain jira
```

## Install

```console
cargo install -f browsercookie-rs
```

## Feature Matrix

| TargetOS | Firefox | Chrome |
|----------|---------|--------|
| Linux |||
| macOS |||
| Windows |||

## Contributions

Contributions are very welcome. The easiest way to contribute is to look at the Python library [browser_cookie3](https://github.com/borisbabic/browser_cookie3), try to mimic the behavior that this library lacks, and submit a pull request. Make sure to format it, use Clippy, and include some tests.
74 changes: 0 additions & 74 deletions README.rst

This file was deleted.

8 changes: 4 additions & 4 deletions src/firefox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ async fn load_from_sqlite(

if domain_regex.0.is_match(&host) {
cookie_jar.add(
Cookie::build(name, value)
Cookie::build((name, value))
.domain(host)
.path("/")
.secure(false)
.http_only(false)
.finish(),
.build(),
);
}
}
Expand Down Expand Up @@ -166,12 +166,12 @@ async fn load_from_recovery(
// println!("Loading for {}: {}={}", cookie.host, cookie.name, cookie.value);
if regex_and_attribute.0.is_match(&cookie.host) {
cookie_jar.add(
Cookie::build(cookie.name, cookie.value)
Cookie::build((cookie.name, cookie.value))
.domain(cookie.host)
.path(cookie.path)
.secure(cookie.secure)
.http_only(cookie.httponly)
.finish(),
.build(),
);
}
}
Expand Down

0 comments on commit 82367df

Please sign in to comment.