{"id":22297489,"url":"https://github.com/rustonaut/quoted-string","last_synced_at":"2025-12-12T16:25:28.903Z","repository":{"id":57658243,"uuid":"109716701","full_name":"rustonaut/quoted-string","owner":"rustonaut","description":"This crate provides utilities to handle quoted strings (in Mail, Mime-Types, etc.) in rust.","archived":false,"fork":false,"pushed_at":"2019-10-11T14:39:34.000Z","size":77,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-15T18:04:28.503Z","etag":null,"topics":["mail","mime","rfc2045","rfc5322","rfc6532","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustonaut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-06T15:56:35.000Z","updated_at":"2025-03-27T03:28:28.000Z","dependencies_parsed_at":"2022-08-25T17:00:38.411Z","dependency_job_id":null,"html_url":"https://github.com/rustonaut/quoted-string","commit_stats":null,"previous_names":["dac-gmbh/quoted-string"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rustonaut/quoted-string","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Fquoted-string","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Fquoted-string/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Fquoted-string/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Fquoted-string/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustonaut","download_url":"https://codeload.github.com/rustonaut/quoted-string/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Fquoted-string/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262003915,"owners_count":23243346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mail","mime","rfc2045","rfc5322","rfc6532","rust"],"created_at":"2024-12-03T17:49:56.503Z","updated_at":"2025-12-12T16:25:28.853Z","avatar_url":"https://github.com/rustonaut.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"quoted-string [![Crates.io](https://img.shields.io/crates/v/quoted-string.svg)](https://crates.io/crates/quoted-string) [![quoted-string](https://docs.rs/quoted-string/badge.svg)](https://docs.rs/quoted-string) [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) [![Build Status](https://travis-ci.org/1aim/quoted-string.svg?branch=master)](https://travis-ci.org/1aim/quoted-string)\n=============\n\nThis crate provides utilities to handle quoted strings like such appearing\nin Media Types (both MIME (i.e. Mail) and HTTP). As there are many small but significant\n differences in different specifications this crate does not provide\na specific implementation. Instead a `QuotedStringSpec` trait is\nexposed. Implementing it (on zero-sized types) should allow the\nusage with any quoted-string specification.\n\nAvailable functionality contains\n--------------------------------\n\n- `quote_if_needed` (\u0026`quote`): quotes content (if needed), the `UnquotedValidator`\n  part of `QuotedStringSpec` can be used to specify which values are valid without\n  needing to be represented as a quoted string. E.g. in a Media Type a parameter\n  value of `abc` can and should be directly represented on benefit `quoted_if_needed`\n  is that it returns a `Cow` so the string is only copied if it actually needs to be\n  represented as quoted string.\n\n- `to_content`: retrieve the _content_ of a quoted string which means that the\n  surrounding `'\"'` quotes will be removed and any quoted-pair (e.g. `\"\\\\\\\"\"`/`r#\"\\\"\"#`)\n  will be replaced with it's value. This function returns `Cow::Borrowed` if there are\n  no quoted-pairs preventing needless allocations.\n\n- `ContentChars`: an iterator over the chars of the content of a quoted-string,\n  i.e. it will strip the surrounding `DQUOTE`s and will ()on the fly) unquote\n  quoted-pairs not needing any extra memory allocations. This can be used to\n  _semantically_ compare two quoted strings regardless of how they used\n  `quoted-pair`s, it implements `Eq`.\n\n- `parse` (\u0026`validate`):  parses a quoted-string positioned at the start of the input.\n  It is written to be easily integrateable with `nom` (through does not require `nom`\n  in any way, using it standalone is as easy)\n\nExample\n-------\n\n```rust\nextern crate quoted_string;\n\n// we use a QuotedStringSpec provided for testing here,\n// not that it's made to hit some edge cases in a simple way\n// so it does not correspond to any used real Spec\nuse quoted_string::test_utils::{TestSpec as Spec};\nuse quoted_string::spec::AsciiWordValidator;\nuse quoted_string::{parse, quote, quote_if_needed, to_content};\n\nfn main() {\n    let res = parse::\u003cSpec\u003e(\"\\\"quoted\\\\\\\"st\\\\ring\\\"; tail=x\").unwrap();\n    let qs = res.quoted_string;\n    assert_eq!(qs, \"\\\"quoted\\\\\\\"st\\\\ring\\\"\");\n    assert_eq!(res.tail, \"; tail=x\");\n    let content = to_content::\u003cSpec\u003e(qs)\n        .expect(\"[BUG] to_content is guaranteed to succeed if input is a valid quoted string\");\n    assert_eq!(content, \"quoted\\\"string\");\n    let re_quoted = quote::\u003cSpec\u003e(\u0026*content)\n        .expect(\"[BUG] quote is guaranteed to succeed if the input is representable in a quoted string\");\n    assert_eq!(re_quoted, \"\\\"quoted\\\\\\\"string\\\"\");\n\n    // TestSpec specifies us-ascii words with 6 letters need no quoting\n    let mut without_quoting = AsciiWordValidator;\n    let out = quote_if_needed::\u003cSpec, _\u003e(\"simple\", \u0026mut without_quoting).unwrap();\n    assert_eq!(\u0026*out, \"simple\");\n}\n\n\n```\n\nLicense\n--------\n\nLicensed under either of\n\n- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\nContribution\n------------\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n\nChange Log\n----------\n\n- **0.3.0**: Made the crate independent of any specific quoted-string specification by\n  introducing `QuotedStringSpec` as there are to many differences between quoted-string's\n  in Media Type occurring in HTTP and thus occurring in MIME (Mail)\n\n- **0.3.1**: Noticed that `ValidationResult` was not exposed, but also\n  didn't got a private type in public interface warning... fixed that\n\n- **0.4.0**:\n  - Removed `Escape` from `ValidationResult`\n  - Renamed `NotSemanticWs` to `NotSemantic`\n  - Renamed `Quotable` to `NeedsQuotedPair`\n  - Removed unnecessary `Err` Associated Type from `UnquotedValidator`\n  - added default impl for `end_validation` of `UnquotedValidator` and`QuotedValidator`\n\n- **0.5.0**:\n  - Changed Spec to use a automaton internally\n  - renamed `strip_quotes` to `strip_dquotes`\n  - default impl for WithoutQuotingValidator::end\n\n- **0.6.0**:\n  - min rust version is now `rustc v1.24`\n  - added `AsciiWordValidator`\n  - fixed example in README","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustonaut%2Fquoted-string","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustonaut%2Fquoted-string","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustonaut%2Fquoted-string/lists"}