Skip to content

Commit cfa8dd9

Browse files
authored
Don't include private_constant-ed module (#155)
Included constants are not private. So private constants in private module aren't private. See also: #154 (comment)
1 parent 4c28808 commit cfa8dd9

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/rexml/parsers/baseparser.rb

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ module Private
134134
ENTITYDECL_PATTERN = /(?:#{GEDECL_PATTERN})|(?:#{PEDECL_PATTERN})/um
135135
end
136136
private_constant :Private
137-
include Private
138137

139138
def initialize( source )
140139
self.stream = source
@@ -302,7 +301,7 @@ def pull_event
302301
raise REXML::ParseException.new( "Bad ELEMENT declaration!", @source ) if md.nil?
303302
return [ :elementdecl, "<!ELEMENT" + md[1] ]
304303
elsif @source.match("ENTITY", true)
305-
match = [:entitydecl, *@source.match(ENTITYDECL_PATTERN, true).captures.compact]
304+
match = [:entitydecl, *@source.match(Private::ENTITYDECL_PATTERN, true).captures.compact]
306305
ref = false
307306
if match[1] == '%'
308307
ref = true
@@ -328,7 +327,7 @@ def pull_event
328327
match << '%' if ref
329328
return match
330329
elsif @source.match("ATTLIST", true)
331-
md = @source.match(ATTLISTDECL_END, true)
330+
md = @source.match(Private::ATTLISTDECL_END, true)
332331
raise REXML::ParseException.new( "Bad ATTLIST declaration!", @source ) if md.nil?
333332
element = md[1]
334333
contents = md[0]
@@ -397,7 +396,7 @@ def pull_event
397396
if @source.match("/", true)
398397
@nsstack.shift
399398
last_tag = @tags.pop
400-
md = @source.match(CLOSE_PATTERN, true)
399+
md = @source.match(Private::CLOSE_PATTERN, true)
401400
if md and !last_tag
402401
message = "Unexpected top-level end tag (got '#{md[1]}')"
403402
raise REXML::ParseException.new(message, @source)
@@ -431,7 +430,7 @@ def pull_event
431430
return process_instruction(start_position)
432431
else
433432
# Get the next tag
434-
md = @source.match(TAG_PATTERN, true)
433+
md = @source.match(Private::TAG_PATTERN, true)
435434
unless md
436435
@source.position = start_position
437436
raise REXML::ParseException.new("malformed XML: missing tag start", @source)
@@ -539,7 +538,7 @@ def need_source_encoding_update?(xml_declaration_encoding)
539538
end
540539

541540
def parse_name(base_error_message)
542-
md = @source.match(NAME_PATTERN, true)
541+
md = @source.match(Private::NAME_PATTERN, true)
543542
unless md
544543
if @source.match(/\s*\S/um)
545544
message = "#{base_error_message}: invalid name"
@@ -618,7 +617,7 @@ def parse_id_invalid_details(accept_external_id:,
618617
end
619618

620619
def process_instruction(start_position)
621-
match_data = @source.match(INSTRUCTION_END, true)
620+
match_data = @source.match(Private::INSTRUCTION_END, true)
622621
unless match_data
623622
message = "Invalid processing instruction node"
624623
@source.position = start_position

lib/rexml/source.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ module Private
6363
end
6464
end
6565
private_constant :Private
66-
include Private
6766

6867
# Constructor
6968
# @param arg must be a String, and should be a valid XML document

0 commit comments

Comments
 (0)