html-escape-0.2.9/.cargo_vcs_info.json0000644000000001120000000000000132370ustar { "git": { "sha1": "31fe418e37cdcb5a5b064ff078fbaac4ae753820" } } html-escape-0.2.9/Cargo.toml0000644000000023750000000000000112520ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] edition = "2018" name = "html-escape" version = "0.2.9" authors = ["Magic Len "] include = ["src/**/*", "Cargo.toml", "README.md", "LICENSE", "benches/encode.rs"] description = "This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well." homepage = "https://magiclen.org/html-escape" readme = "README.md" keywords = ["html", "escape", "unescape", "encode", "decode"] categories = ["no-std", "encoding"] license = "MIT" repository = "https://github.com/magiclen/html-escape" [[bench]] name = "encode" harness = false required-features = ["std"] [dependencies.utf8-width] version = "0.1" [dev-dependencies.bencher] version = "0.1.5" [features] default = ["std"] std = [] html-escape-0.2.9/Cargo.toml.orig000064400000000000000000000013410000000000000147010ustar 00000000000000[package] name = "html-escape" version = "0.2.9" authors = ["Magic Len "] edition = "2018" repository = "https://github.com/magiclen/html-escape" homepage = "https://magiclen.org/html-escape" keywords = ["html", "escape", "unescape", "encode", "decode"] categories = ["no-std", "encoding"] description = "This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well." readme = "README.md" license = "MIT" include = ["src/**/*", "Cargo.toml", "README.md", "LICENSE", "benches/encode.rs"] [dependencies] utf8-width = "0.1" [dev-dependencies] bencher = "0.1.5" [features] default = ["std"] std = [] [[bench]] name = "encode" required-features = ["std"] harness = falsehtml-escape-0.2.9/LICENSE000064400000000000000000000020660000000000000130240ustar 00000000000000MIT License Copyright (c) 2020 magiclen.org (Ron Li) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. html-escape-0.2.9/README.md000064400000000000000000000042540000000000000132770ustar 00000000000000HTML Escape ==================== [![CI](https://github.com/magiclen/html-escape/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/html-escape/actions/workflows/ci.yml) This library is for encoding/escaping special characters in HTML and decoding/unescaping HTML entities as well. ## Usage ### Encoding This crate provides some `encode_*` functions to encode HTML text in different situations. For example, to put a text between a start tag `` and an end tag ``, use the `encode_text` function to escape every `&`, `<`, and `>` in the text. ```rust extern crate html_escape; assert_eq!("a > b && a < c", html_escape::encode_text("a > b && a < c")); ``` The functions suffixed with `_to_writer`, `_to_vec` or `_to_string` are useful to generate HTML. ```rust extern crate html_escape; let mut html = String::from("", &mut html)); html.push_str("');"); assert_eq!("", html); ``` ### Decoding ```rust extern crate html_escape; assert_eq!("Hello world!", html_escape::decode_html_entities("Hello world!")); ``` ```rust extern crate html_escape; assert_eq!("alert(');'", html_escape::decode_script(r"alert('` parse_script; /// Decode text from the `` /// * `\'` => `'` parse_script_single_quoted_text; /// Decode text from a single quoted text in the `` /// * `\"` => `"` parse_script_double_quoted_text; /// Decode text from a double quoted text in the `` /// * `\"` => `"` /// * `\'` => `'` parse_script_quoted_text; /// Decode text from a quoted text in the `` => `<\/script>` parse_script; /// Encode text used in the `` => `<\/script>` /// * `'` => `\'` parse_script_single_quoted_text; /// Encode text used in a single quoted text in the `` => `<\/script>` /// * `"` => `\"` parse_script_double_quoted_text; /// Encode text used in a double quoted text in the `` => `<\/script>` /// * `"` => `\"` /// * `'` => `\'` parse_script_quoted_text; /// Encode text used in a quoted text in the `", &mut html)); html.push_str("');"); assert_eq!("", html); ``` ### Decoding ```rust extern crate html_escape; assert_eq!("Hello world!", html_escape::decode_html_entities("Hello world!")); ``` ```rust extern crate html_escape; assert_eq!("alert('');", html_escape::decode_script(r"alert('