• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

.gitignoreH A D06-Aug-2018252

.travis.ymlH A D06-Aug-201813

LICENSEH A D06-Aug-20181.4 KiB

README.mdH A D06-Aug-20181.9 KiB

sanitize.goH A D06-Aug-201810.3 KiB

sanitize_test.goH A D06-Aug-201811.5 KiB

README.md

1sanitize [![GoDoc](https://godoc.org/github.com/kennygrant/sanitize?status.svg)](https://godoc.org/github.com/kennygrant/sanitize) [![Go Report Card](https://goreportcard.com/badge/github.com/kennygrant/sanitize)](https://goreportcard.com/report/github.com/kennygrant/sanitize) [![CircleCI](https://circleci.com/gh/kennygrant/sanitize.svg?style=svg)](https://circleci.com/gh/kennygrant/sanitize)
2========
3
4Package sanitize provides functions to sanitize html and paths with go (golang).
5
6FUNCTIONS
7
8
9```go
10sanitize.Accents(s string) string
11```
12
13Accents replaces a set of accented characters with ascii equivalents.
14
15```go
16sanitize.BaseName(s string) string
17```
18
19BaseName makes a string safe to use in a file name, producing a sanitized basename replacing . or / with -. Unlike Name no attempt is made to normalise text as a path.
20
21```go
22sanitize.HTML(s string) string
23```
24
25HTML strips html tags with a very simple parser, replace common entities, and escape < and > in the result. The result is intended to be used as plain text.
26
27```go
28sanitize.HTMLAllowing(s string, args...[]string) (string, error)
29```
30
31HTMLAllowing parses html and allow certain tags and attributes from the lists optionally specified by args - args[0] is a list of allowed tags, args[1] is a list of allowed attributes. If either is missing default sets are used.
32
33```go
34sanitize.Name(s string) string
35```
36
37Name makes a string safe to use in a file name by first finding the path basename, then replacing non-ascii characters.
38
39```go
40sanitize.Path(s string) string
41```
42
43Path makes a string safe to use as an url path.
44
45
46Changes
47-------
48
49Version 1.2
50
51Adjusted HTML function to avoid linter warning
52Added more tests from https://githubengineering.com/githubs-post-csp-journey/
53Chnaged name of license file
54Added badges and change log to readme
55
56Version 1.1
57Fixed type in comments.
58Merge pull request from Povilas Balzaravicius Pawka
59 - replace br tags with newline even when they contain a space
60
61Version 1.0
62First release