Skip to content

Commit

Permalink
Add support for REXML 3.3.2 or later
Browse files Browse the repository at this point in the history
SAX2 API expands entities since REXML 3.3.2.
  • Loading branch information
kou committed Sep 22, 2024
1 parent f9df936 commit 581ccbb
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions lib/chupa-text/sax-parser.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2019 Kouhei Sutou <[email protected]>
# Copyright (C) 2019-2024 Sutou Kouhei <[email protected]>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
Expand All @@ -16,6 +16,7 @@

require "cgi/util"
require "rexml/parsers/sax2parser"
require "rexml/rexml"
require "rexml/sax2listener"

begin
Expand Down Expand Up @@ -156,12 +157,22 @@ def end_element(*args)
@listener.end_element(*args)
end

def characters(text)
@listener.characters(CGI.unescapeHTML(text))
end
if (REXML::VERSION <=> "3.3.2") >= 0
def characters(text)
@listener.characters(text)
end

def cdata(content)
@listener.cdata(content)
end
else
def characters(text)
@listener.characters(CGI.unescapeHTML(text))
end

def cdata(content)
@listener.cdata(CGI.unescapeHTML(content))
def cdata(content)
@listener.cdata(CGI.unescapeHTML(content))
end
end
end
end
Expand Down

0 comments on commit 581ccbb

Please sign in to comment.