sanitize

Package sanitize provides functions for sanitizing text in golang strings.

  • 所有者: kennygrant/sanitize
  • 平台:
  • 许可证: BSD 3-Clause "New" or "Revised" License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

sanitize GoDoc Go Report Card CircleCI

Package sanitize provides functions to sanitize html and paths with go (golang).

FUNCTIONS

sanitize.Accents(s string) string

Accents replaces a set of accented characters with ascii equivalents.

sanitize.BaseName(s string) string

BaseName 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.

sanitize.HTML(s string) string

HTML 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.

sanitize.HTMLAllowing(s string, args...[]string) (string, error)

HTMLAllowing 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.

sanitize.Name(s string) string

Name makes a string safe to use in a file name by first finding the path basename, then replacing non-ascii characters.

sanitize.Path(s string) string

Path makes a string safe to use as an url path.

Changes

Version 1.2

Adjusted HTML function to avoid linter warning
Added more tests from https://githubengineering.com/githubs-post-csp-journey/
Chnaged name of license file
Added badges and change log to readme

Version 1.1
Fixed type in comments.
Merge pull request from Povilas Balzaravicius Pawka

  • replace br tags with newline even when they contain a space

Version 1.0
First release

主要指标

概览
名称与所有者kennygrant/sanitize
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证BSD 3-Clause "New" or "Revised" License
所有者活动
创建于2013-03-16 09:57:27
推送于2022-09-04 14:33:30
最后一次提交2018-08-06 08:34:57
发布数7
最新版本名称v1.2.4 (发布于 )
第一版名称v1.0 (发布于 )
用户参与
星数336
关注者数12
派生数71
提交数59
已启用问题?
问题数7
打开的问题数2
拉请求数10
打开的拉请求数7
关闭的拉请求数7
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?