Skip to content

Commit a8ac8bf

Browse files
committed
Imported the REXML patches.
1 parent ecec782 commit a8ac8bf

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (c) 2008 Michael Koziarski <[email protected]>
2+
#
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
#
7+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
15+
require 'rexml/document'
16+
require 'rexml/entity'
17+
18+
module REXML
19+
class Entity < Child
20+
def unnormalized
21+
document.record_entity_expansion!
22+
v = value()
23+
return nil if v.nil?
24+
@unnormalized = Text::unnormalize(v, parent)
25+
@unnormalized
26+
end
27+
end
28+
class Document < Element
29+
@@entity_expansion_limit = 10_000
30+
def self.entity_expansion_limit= val
31+
@@entity_expansion_limit = val
32+
end
33+
34+
def record_entity_expansion!
35+
@number_of_expansions ||= 0
36+
@number_of_expansions += 1
37+
if @number_of_expansions > @@entity_expansion_limit
38+
raise "Number of entity expansions exceeded, processing aborted."
39+
end
40+
end
41+
end
42+
end
43+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Copyright (c) 2008 Michael Koziarski <[email protected]>
2+
#
3+
# Permission to use, copy, modify, and/or distribute this software for any
4+
# purpose with or without fee is hereby granted, provided that the above
5+
# copyright notice and this permission notice appear in all copies.
6+
#
7+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14+
15+
require 'rexml/document'
16+
require 'rexml/entity'
17+
18+
module REXML
19+
class Entity < Child
20+
def unnormalized
21+
document.record_entity_expansion unless document.nil?
22+
v = value()
23+
return nil if v.nil?
24+
@unnormalized = Text::unnormalize(v, parent)
25+
@unnormalized
26+
end
27+
end
28+
class Document < Element
29+
@@entity_expansion_limit = 10_000
30+
def self.entity_expansion_limit= val
31+
@@entity_expansion_limit = val
32+
end
33+
34+
def record_entity_expansion!
35+
@number_of_expansions ||= 0
36+
@number_of_expansions += 1
37+
if @number_of_expansions > @@entity_expansion_limit
38+
raise "Number of entity expansions exceeded, processing aborted."
39+
end
40+
end
41+
end
42+
end
43+

0 commit comments

Comments
 (0)