-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for REXML 3.3.2 or later
SAX2 API expands entities since REXML 3.3.2.
- Loading branch information
Showing
1 changed file
with
17 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -16,6 +16,7 @@ | |
|
||
require "cgi/util" | ||
require "rexml/parsers/sax2parser" | ||
require "rexml/rexml" | ||
require "rexml/sax2listener" | ||
|
||
begin | ||
|
@@ -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 | ||
|