mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 08:11:42 +00:00
normalizar todas las strings
convierte la codificación de windows/osx en unicode normalizado.
This commit is contained in:
parent
ecb823f407
commit
455070f2ea
5 changed files with 10 additions and 7 deletions
|
@ -12,6 +12,6 @@ class MetadataMarkdown < MetadataText
|
|||
# markdown y se eliminan autolinks. Mejor es habilitar la generación
|
||||
# SAFE de CommonMark en la configuración del sitio.
|
||||
def sanitize(string)
|
||||
string
|
||||
string.unicode_normalize(:nfkc)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,6 +25,6 @@ class MetadataMarkdownContent < MetadataText
|
|||
# markdown y se eliminan autolinks. Mejor es deshabilitar la
|
||||
# generación SAFE de CommonMark en la configuración del sitio.
|
||||
def sanitize(string)
|
||||
string.tr("\r", '')
|
||||
string.tr("\r", '').unicode_normalize(:nfkc)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@ class MetadataPermalink < MetadataString
|
|||
# puntos suspensivos, la primera / para que siempre sea relativa y
|
||||
# agregamos una / al final si la ruta no tiene extensión.
|
||||
def sanitize(value)
|
||||
value = value.strip.gsub('..', '/').gsub('./', '').squeeze('/')
|
||||
value = value.strip.unicode_normalize(:nfkc).gsub('..', '/').gsub('./', '').squeeze('/')
|
||||
value = value[1..-1] if value.start_with? '/'
|
||||
value += '/' if File.extname(value).blank?
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class MetadataString < MetadataTemplate
|
|||
def sanitize(string)
|
||||
return '' if string.blank?
|
||||
|
||||
sanitizer.sanitize(string.strip,
|
||||
sanitizer.sanitize(string.strip.unicode_normalize(:nfkc),
|
||||
tags: [],
|
||||
attributes: []).strip.html_safe
|
||||
end
|
||||
|
|
|
@ -184,9 +184,12 @@ MetadataTemplate = Struct.new(:site, :document, :name, :label, :type,
|
|||
return if string.nil?
|
||||
return string unless string.is_a? String
|
||||
|
||||
sanitizer.sanitize(string.tr("\r", ''),
|
||||
tags: allowed_tags,
|
||||
attributes: allowed_attributes).strip.html_safe
|
||||
sanitizer
|
||||
.sanitize(string.tr("\r", '').unicode_normalize(:nfkc),
|
||||
tags: allowed_tags,
|
||||
attributes: allowed_attributes)
|
||||
.strip
|
||||
.html_safe
|
||||
end
|
||||
|
||||
def sanitizer
|
||||
|
|
Loading…
Reference in a new issue