tvcal: Work around buggy 0x0d at end of lines
authorMikael Berthe <mikael@lilotux.net>
Sat, 29 Sep 2012 12:50:48 +0200
changeset 61 5d807892b439
parent 60 74697f376dad
child 62 3de76c87294b
tvcal: Work around buggy 0x0d at end of lines I always wonder how people can generate such ugly HTML code pages...
mcbot/cmds/tvcal.lua
--- a/mcbot/cmds/tvcal.lua	Sat Sep 29 11:40:10 2012 +0200
+++ b/mcbot/cmds/tvcal.lua	Sat Sep 29 12:50:48 2012 +0200
@@ -32,14 +32,17 @@
         return nil, "Could not fetch calendar, please try again later!"
     end
 
+    -- Work around frackin ugly end of line characters... :/
+    local eol = "[%s"..string.char(13).."]*"
+
     -- Regex for each day
     local tabregex = '<td id="d_(%d+_%d+_%d%d%d%d)" class="t?o?day"%s*>'..
                      '%s*(.-)%s*</td>'
 
     -- Regex for parsing one day
     local epregex = '<p[^>]*>'..
-                      '<a href=[^>]+>([^<]+)</a>'..       -- Name
-                      '<br /><a href=[^>]+>([^<]+)</a>'.. -- Episode
+                      '<a href=[^>]+>([^<]+)</a>'..eol..        -- Name
+                      '<br /><a href=[^>]+>([^<]+)</a>'..eol..  -- Episode
                     '</p>'
 
     -- loop over all days