Character encoding extreme!!!

._.
This commit is contained in:
Akamaru 2016-02-09 16:22:12 +01:00
parent 2f421ab901
commit d6ae7ebf23
7 changed files with 68 additions and 236 deletions

View File

@ -528,17 +528,51 @@ function round(num, idp)
end
function unescape(str)
str = string.gsub( str, '&lt;', '<' )
str = string.gsub( str, '&gt;', '>' )
str = string.gsub( str, '&quot;', '"' )
str = string.gsub( str, '&apos;', "'" )
str = string.gsub( str, "&Auml;", "Ä")
str = string.gsub( str, "&auml;", "ä")
str = string.gsub( str, "&Ouml;", "Ö")
str = string.gsub( str, "&ouml;", "ö")
str = string.gsub( str, "Uuml;", "Ü")
str = string.gsub( str, "&uuml;", "ü")
str = string.gsub( str, "&szlig;", "ß")
-- Character encoding
str = string.gsub(str, "&acute;", "´")
str = string.gsub(str, "&bull;", "")
str = string.gsub(str, "&gt;", ">")
str = string.gsub(str, "&hellip;", "")
str = string.gsub(str, "&lt;", "<")
str = string.gsub(str, "&mdash;", "")
str = string.gsub(str, "&nabla;", "")
str = string.gsub(str, "&ndash;", "")
str = string.gsub(str, "&Psi;", "ψ")
str = string.gsub(str, "&psi;", "ψ")
str = string.gsub(str, "&quot;", '"')
str = string.gsub(str, "&raquo;", "»")
str = string.gsub(str, "&reg;", "®")
str = string.gsub(str, "&szlig;", "ß")
str = string.gsub(str, "&trade;", "")
str = string.gsub(str, "&#038;", "&")
str = string.gsub(str, "&#039;", "'")
str = string.gsub(str, "&#39;", "'")
str = string.gsub(str, "&#124;", "|")
str = string.gsub(str, "&#160;", " ")
str = string.gsub(str, "&#174;", "®")
str = string.gsub(str, "&#187;", "»")
str = string.gsub(str, "&#223;", "ß")
str = string.gsub(str, "&#8211;", "")
str = string.gsub(str, "&#8217;", "'")
str = string.gsub(str, "&#8220;", "")
str = string.gsub(str, "&#8221;", "")
str = string.gsub(str, "&#8222;", "")
str = string.gsub(str, "&#8249;", "")
str = string.gsub(str, "&#8364;", "")
-- Ä Ö Ü
str = string.gsub(str, "&auml;", "ä")
str = string.gsub(str, "&Auml;", "Ä")
str = string.gsub(str, "&#228;", "ä")
str = string.gsub(str, "&#196;", "Ä")
str = string.gsub(str, "&ouml;", "ö")
str = string.gsub(str, "&Ouml;", "Ö")
str = string.gsub(str, "&#246;", "ö")
str = string.gsub(str, "&#214;", "Ö")
str = string.gsub(str, "&uuml;", "ü")
str = string.gsub(str, "&Uuml;", "Ü")
str = string.gsub(str, "&#252;", "ü")
str = string.gsub(str, "&#220;", "Ü")
str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
str = string.gsub( str, '&amp;', '&' ) -- Be sure to do this after all others

View File

@ -13,52 +13,13 @@ local function get_post(post)
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local title = data.title
-- Character encoding
title = string.gsub(title, "&acute;", "´")
title = string.gsub(title, "&amp;", "&")
title = string.gsub(title, "&gt;", ">")
title = string.gsub(title, "&quot;", '"')
title = string.gsub(title, "&lt;", "<")
title = string.gsub(title, "&mdash;", "")
title = string.gsub(title, "&nabla;", "")
title = string.gsub(title, "&ndash;", "")
title = string.gsub(title, "&Psi;", "ψ")
title = string.gsub(title, "&psi;", "ψ")
title = string.gsub(title, "&raquo;", "»")
title = string.gsub(title, "&szlig;", "ß")
title = string.gsub(title, "&trade;", "")
title = string.gsub(title, "&#038;", "&")
title = string.gsub(title, "&#039;", "'")
title = string.gsub(title, "&#39;", "'")
title = string.gsub(title, "&#124;", "|")
title = string.gsub(title, "&#160;", " ")
title = string.gsub(title, "&#187;", "»")
title = string.gsub(title, "&#223;", "ß")
title = string.gsub(title, "&#8211;", "")
title = string.gsub(title, "&#8217;", "'")
title = string.gsub(title, "&#8220;", "")
title = string.gsub(title, "&#8221;", "")
title = string.gsub(title, "&#8222;", "")
title = string.gsub(title, "&#8249;", "")
title = string.gsub(title, "&#8364;", "")
-- Ä Ö Ü
title = string.gsub(title, "&auml;", "ä")
title = string.gsub(title, "&Auml;", "Ä")
title = string.gsub(title, "&#228;", "ä")
title = string.gsub(title, "&#196;", "Ä")
title = string.gsub(title, "&ouml;", "ö")
title = string.gsub(title, "&Ouml;", "Ö")
title = string.gsub(title, "&#246;", "ö")
title = string.gsub(title, "&#214;", "Ö")
title = string.gsub(title, "&uuml;", "ü")
title = string.gsub(title, "&Uuml;", "Ü")
title = string.gsub(title, "&#252;", "ü")
title = string.gsub(title, "&#220;", "Ü")
local title = unescape(data.title)
local from = data.author.name
local date = makeOurDate(data.date)
local content = string.match(data.excerpt, '<p>(.*)<span')
local content = unescape(string.match(data.excerpt, '<p>(.*)<span'))
if not content then
content = unescape(string.match(data.excerpt, '<p>(.*)</p>'))
end
local url = data.url
if data.thumbnail then
image_url = data.thumbnail

View File

@ -13,52 +13,13 @@ local function search_post(tag)
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "Nichts gefunden!" end
local title = data.title
-- Character encoding
title = string.gsub(title, "&acute;", "´")
title = string.gsub(title, "&amp;", "&")
title = string.gsub(title, "&gt;", ">")
title = string.gsub(title, "&quot;", '"')
title = string.gsub(title, "&lt;", "<")
title = string.gsub(title, "&mdash;", "")
title = string.gsub(title, "&nabla;", "")
title = string.gsub(title, "&ndash;", "")
title = string.gsub(title, "&Psi;", "ψ")
title = string.gsub(title, "&psi;", "ψ")
title = string.gsub(title, "&raquo;", "»")
title = string.gsub(title, "&szlig;", "ß")
title = string.gsub(title, "&trade;", "")
title = string.gsub(title, "&#038;", "&")
title = string.gsub(title, "&#039;", "'")
title = string.gsub(title, "&#39;", "'")
title = string.gsub(title, "&#124;", "|")
title = string.gsub(title, "&#160;", " ")
title = string.gsub(title, "&#187;", "»")
title = string.gsub(title, "&#223;", "ß")
title = string.gsub(title, "&#8211;", "")
title = string.gsub(title, "&#8217;", "'")
title = string.gsub(title, "&#8220;", "")
title = string.gsub(title, "&#8221;", "")
title = string.gsub(title, "&#8222;", "")
title = string.gsub(title, "&#8249;", "")
title = string.gsub(title, "&#8364;", "")
-- Ä Ö Ü
title = string.gsub(title, "&auml;", "ä")
title = string.gsub(title, "&Auml;", "Ä")
title = string.gsub(title, "&#228;", "ä")
title = string.gsub(title, "&#196;", "Ä")
title = string.gsub(title, "&ouml;", "ö")
title = string.gsub(title, "&Ouml;", "Ö")
title = string.gsub(title, "&#246;", "ö")
title = string.gsub(title, "&#214;", "Ö")
title = string.gsub(title, "&uuml;", "ü")
title = string.gsub(title, "&Uuml;", "Ü")
title = string.gsub(title, "&#252;", "ü")
title = string.gsub(title, "&#220;", "Ü")
local title = unescape(data.title)
local from = data.author.name
local date = makeOurDate(data.date)
local content = string.match(data.excerpt, '<p>(.*)<span')
local content = unescape(string.match(data.excerpt, '<p>(.*)<span'))
if not content then
content = unescape(string.match(data.excerpt, '<p>(.*)</p>'))
end
local url = data.url
if data.thumbnail then
image_url = data.thumbnail

View File

@ -13,52 +13,10 @@ local function get_post(post)
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local title = data.title
-- Character encoding
title = string.gsub(title, "&acute;", "´")
title = string.gsub(title, "&amp;", "&")
title = string.gsub(title, "&gt;", ">")
title = string.gsub(title, "&quot;", '"')
title = string.gsub(title, "&lt;", "<")
title = string.gsub(title, "&mdash;", "")
title = string.gsub(title, "&nabla;", "")
title = string.gsub(title, "&ndash;", "")
title = string.gsub(title, "&Psi;", "ψ")
title = string.gsub(title, "&psi;", "ψ")
title = string.gsub(title, "&raquo;", "»")
title = string.gsub(title, "&szlig;", "ß")
title = string.gsub(title, "&trade;", "")
title = string.gsub(title, "&#038;", "&")
title = string.gsub(title, "&#039;", "'")
title = string.gsub(title, "&#39;", "'")
title = string.gsub(title, "&#124;", "|")
title = string.gsub(title, "&#160;", " ")
title = string.gsub(title, "&#187;", "»")
title = string.gsub(title, "&#223;", "ß")
title = string.gsub(title, "&#8211;", "")
title = string.gsub(title, "&#8217;", "'")
title = string.gsub(title, "&#8220;", "")
title = string.gsub(title, "&#8221;", "")
title = string.gsub(title, "&#8222;", "")
title = string.gsub(title, "&#8249;", "")
title = string.gsub(title, "&#8364;", "")
-- Ä Ö Ü
title = string.gsub(title, "&auml;", "ä")
title = string.gsub(title, "&Auml;", "Ä")
title = string.gsub(title, "&#228;", "ä")
title = string.gsub(title, "&#196;", "Ä")
title = string.gsub(title, "&ouml;", "ö")
title = string.gsub(title, "&Ouml;", "Ö")
title = string.gsub(title, "&#246;", "ö")
title = string.gsub(title, "&#214;", "Ö")
title = string.gsub(title, "&uuml;", "ü")
title = string.gsub(title, "&Uuml;", "Ü")
title = string.gsub(title, "&#252;", "ü")
title = string.gsub(title, "&#220;", "Ü")
local title = unescape(data.title)
local from = data.author.name
local date = makeOurDate(data.date)
local content = string.match(data.excerpt, '<p>(.*)</p>')
local content = unescape(string.match(data.excerpt, '<p>(.*)</p>'))
local url = data.url
if data.thumbnail then
image_url = data.thumbnail

View File

@ -1,44 +1,6 @@
feedparser = (loadfile "./libs/feedparser.lua")()
local function unescape_for_rss(str)
-- Character encoding
str = string.gsub(str, "&acute;", "´")
str = string.gsub(str, "&gt;", ">")
str = string.gsub(str, "&lt;", "<")
str = string.gsub(str, "&mdash;", "")
str = string.gsub(str, "&nabla;", "")
str = string.gsub(str, "&ndash;", "")
str = string.gsub(str, "&Psi;", "ψ")
str = string.gsub(str, "&psi;", "ψ")
str = string.gsub(str, "&raquo;", "»")
str = string.gsub(str, "&szlig;", "ß")
str = string.gsub(str, "&#39;", "'")
str = string.gsub(str, "&#124;", "|")
str = string.gsub(str, "&#160;", " ")
str = string.gsub(str, "&#187;", "»")
str = string.gsub(str, "&#223;", "ß")
str = string.gsub(str, "&#8211;", "")
str = string.gsub(str, "&#8217;", "'")
str = string.gsub(str, "&#8220;", "")
str = string.gsub(str, "&#8221;", "")
str = string.gsub(str, "&#8222;", "")
str = string.gsub(str, "&#8249;", "")
str = string.gsub(str, "&#8364;", "")
-- Ä Ö Ü
str = string.gsub(str, "&auml;", "ä")
str = string.gsub(str, "&Auml;", "Ä")
str = string.gsub(str, "&#228;", "ä")
str = string.gsub(str, "&#196;", "Ä")
str = string.gsub(str, "&ouml;", "ö")
str = string.gsub(str, "&Ouml;", "Ö")
str = string.gsub(str, "&#246;", "ö")
str = string.gsub(str, "&#214;", "Ö")
str = string.gsub(str, "&uuml;", "ü")
str = string.gsub(str, "&Uuml;", "Ü")
str = string.gsub(str, "&#252;", "ü")
str = string.gsub(str, "&#220;", "Ü")
str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
str = string.gsub( str, '&amp;', '&' ) -- Be sure to do this after all others
return str
@ -180,19 +142,19 @@ local function cron()
local subscribers = {}
local text = '' -- Send one message per feed with the latest entries
for k2, v2 in pairs(newentr) do
local title = v2.title or 'Kein Titel'
local title = unescape(v2.title) or 'Kein Titel'
local link = v2.link or v2.id or 'Kein Link'
if v2.content then
if string.len(v2.content) > 250 then
content = string.sub(unescape_for_rss(v2.content:gsub("%b<>", "")), 1, 250) .. '...'
content = unescape(string.sub(unescape_for_rss(v2.content:gsub("%b<>", "")), 1, 250))..'...'
else
content = unescape_for_rss(v2.content:gsub("%b<>", ""))
content = unescape(unescape_for_rss(v2.content:gsub("%b<>", "")))
end
elseif v2.summary then
if string.len(v2.summary) > 250 then
content = string.sub(unescape_for_rss(v2.summary:gsub("%b<>", "")), 1, 250) .. '...'
content = unescape(string.sub(unescape_for_rss(v2.summary:gsub("%b<>", "")), 1, 250))..'...'
else
content = unescape_for_rss(v2.summary:gsub("%b<>", ""))
content = unescape(unescape_for_rss(v2.summary:gsub("%b<>", "")))
end
else
content = ''

View File

@ -4,56 +4,9 @@ function getTitle(page)
local s = page
-- Remove optional spaces from the tags.
s = string.gsub(s, "\n", " ")
s = string.gsub(s, " *< *", "<")
s = string.gsub(s, " *> *", ">")
-- Character encoding
s = string.gsub(s, "&acute;", "´")
s = string.gsub(s, "&bull;", "")
s = string.gsub(s, "&gt;", ">")
s = string.gsub(s, "&hellip;", "")
s = string.gsub(s, "&lt;", "<")
s = string.gsub(s, "&mdash;", "")
s = string.gsub(s, "&nabla;", "")
s = string.gsub(s, "&ndash;", "")
s = string.gsub(s, "&Psi;", "ψ")
s = string.gsub(s, "&psi;", "ψ")
s = string.gsub(s, "&quot;", '"')
s = string.gsub(s, "&raquo;", "»")
s = string.gsub(s, "&reg;", "®")
s = string.gsub(s, "&szlig;", "ß")
s = string.gsub(s, "&trade;", "")
s = string.gsub(s, "&#038;", "&")
s = string.gsub(s, "&#039;", "'")
s = string.gsub(s, "&#39;", "'")
s = string.gsub(s, "&#124;", "|")
s = string.gsub(s, "&#160;", " ")
s = string.gsub(s, "&#174;", "®")
s = string.gsub(s, "&#187;", "»")
s = string.gsub(s, "&#223;", "ß")
s = string.gsub(s, "&#8211;", "")
s = string.gsub(s, "&#8217;", "'")
s = string.gsub(s, "&#8220;", "")
s = string.gsub(s, "&#8221;", "")
s = string.gsub(s, "&#8222;", "")
s = string.gsub(s, "&#8249;", "")
s = string.gsub(s, "&#8364;", "")
-- Ä Ö Ü
s = string.gsub(s, "&auml;", "ä")
s = string.gsub(s, "&Auml;", "Ä")
s = string.gsub(s, "&#228;", "ä")
s = string.gsub(s, "&#196;", "Ä")
s = string.gsub(s, "&ouml;", "ö")
s = string.gsub(s, "&Ouml;", "Ö")
s = string.gsub(s, "&#246;", "ö")
s = string.gsub(s, "&#214;", "Ö")
s = string.gsub(s, "&uuml;", "ü")
s = string.gsub(s, "&Uuml;", "Ü")
s = string.gsub(s, "&#252;", "ü")
s = string.gsub(s, "&#220;", "Ü")
-- Put all the tags in lowercase.
s = string.gsub(s, "(<[^ >]+)", string.lower)
s = string.gsub(s, "&amp;", "&") -- Be sure to do this after all others
@ -68,7 +21,7 @@ end
function run(msg, matches)
local url = matches[1]
local result = http.request(url)
local title = getTitle(result)
local title = unescape(getTitle(result))
--Ignoring 301, 302, 404 and more
if title == "301 Moved Permanently" or

View File

@ -29,7 +29,10 @@ end
return {
description = "Send the origin of an IP or domain",
usage = {"!ip (ip): Send the origin of an IP.\n!ip (domain.com) Looks for his IP origin.\nYou can find your ip in: http://lorenzomoreno.es/myip Credits: @rutrus"},
usage = {"/ip (ip): Send the origin of an IP.",
"/ip (domain.com) Looks for his IP origin.",
"You can find your ip in: http://lorenzomoreno.es/myip Credits: @rutrus"
},
patterns = {
"^/whereisip$",
"^/ip$",