[fix] Don't break OPDS parsing on HR tags (#5949)

Apply the same crappy workaround as for BR.

Fix #5948
reviewable/pr5962/r2
NiLuJe 4 years ago committed by GitHub
parent bb0c01757d
commit 098c1a7844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -8,6 +8,7 @@
Pure Lua Version written by: William A Adams Pure Lua Version written by: William A Adams
Dramatic Speed Improvements by: Robert G Jakabosky Dramatic Speed Improvements by: Robert G Jakabosky
https://github.com/Wiladams/LAPHLibs/blob/master/laphlibs/luxl.lua
References References
@ -20,10 +21,15 @@ local ffi = require "ffi"
local bit = require "bit" local bit = require "bit"
local band = bit.band local band = bit.band
--[[ --[[
Types of characters; 0 is not valid, 1 is letters, 2 are digits Types of characters;
(including '.') and 3 whitespace. 0 is not valid
1 is letters,
2 are digits (including '.')
3 whitespace
--]] --]]
local char_type = ffi.new("const int[256]", { local char_type = ffi.new("const int[256]", {
0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 0, 0, 3, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -43,6 +49,8 @@ local char_type = ffi.new("const int[256]", {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
}); });
-- Internal states that the parser can be in at any given time. -- Internal states that the parser can be in at any given time.
local ST_START = 0; -- starting base state; default state local ST_START = 0; -- starting base state; default state
local ST_TEXT =1; -- text state local ST_TEXT =1; -- text state
@ -198,6 +206,7 @@ struct parse_state {
int i; int i;
int ix; /* index into buffer */ int ix; /* index into buffer */
}; };
]] ]]
local cclass_match = { local cclass_match = {

@ -79,6 +79,9 @@ function OPDSParser:parse(text)
-- but will kick the ass of luxl -- but will kick the ass of luxl
text = text:gsub("<br>", "<br />") text = text:gsub("<br>", "<br />")
text = text:gsub("<br/>", "<br />") text = text:gsub("<br/>", "<br />")
-- Same deal with hr
text = text:gsub("<hr>", "<hr />")
text = text:gsub("<hr/>", "<hr />")
-- some OPDS catalogs wrap text in a CDATA section, remove it as it causes parsing problems -- some OPDS catalogs wrap text in a CDATA section, remove it as it causes parsing problems
text = text:gsub("<!%[CDATA%[(.-)%]%]>", function (s) text = text:gsub("<!%[CDATA%[(.-)%]%]>", function (s)
return s:gsub( "%p", {["&"] = "&amp;", ["<"] = "&lt;", [">"] = "&gt;" } ) return s:gsub( "%p", {["&"] = "&amp;", ["<"] = "&lt;", [">"] = "&gt;" } )

Loading…
Cancel
Save