html-escape-0.2.12/.cargo_vcs_info.json0000644000000001360000000000100133200ustar { "git": { "sha1": "e2e292822bf157029980be4de0b35795fc657c47" }, "path_in_vcs": "" }html-escape-0.2.12/Cargo.toml0000644000000023770000000000100113270ustar # 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 are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" name = "html-escape" version = "0.2.12" 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.12/Cargo.toml.orig0000644000000013420000000000100122550ustar [package] name = "html-escape" version = "0.2.12" authors = ["Magic Len "] edition = "2021" 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.12/Cargo.toml.orig000064400000000000000000000013421046102023000147770ustar 00000000000000[package] name = "html-escape" version = "0.2.12" authors = ["Magic Len "] edition = "2021" 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.12/LICENSE000064400000000000000000000020661046102023000131210ustar 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.12/README.md000064400000000000000000000041001046102023000133620ustar 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 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 let mut html = String::from("", &mut html)); html.push_str("');"); assert_eq!("", html); ``` ### Decoding ```rust assert_eq!("Hello world!", html_escape::decode_html_entities("Hello world!")); ``` ```rust 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 assert_eq!("Hello world!", html_escape::decode_html_entities("Hello world!")); ``` ```rust assert_eq!("alert('');", html_escape::decode_script(r"alert('