Skip to content

Commit

Permalink
Don't include private_constant-ed module (#155)
Browse files Browse the repository at this point in the history
Included constants are not private. So private constants in private
module aren't private.

See also: #154 (comment)
  • Loading branch information
naitoh authored Jun 22, 2024
1 parent 4c28808 commit cfa8dd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
13 changes: 6 additions & 7 deletions lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ module Private
ENTITYDECL_PATTERN = /(?:#{GEDECL_PATTERN})|(?:#{PEDECL_PATTERN})/um
end
private_constant :Private
include Private

def initialize( source )
self.stream = source
Expand Down Expand Up @@ -302,7 +301,7 @@ def pull_event
raise REXML::ParseException.new( "Bad ELEMENT declaration!", @source ) if md.nil?
return [ :elementdecl, "<!ELEMENT" + md[1] ]
elsif @source.match("ENTITY", true)
match = [:entitydecl, *@source.match(ENTITYDECL_PATTERN, true).captures.compact]
match = [:entitydecl, *@source.match(Private::ENTITYDECL_PATTERN, true).captures.compact]
ref = false
if match[1] == '%'
ref = true
Expand All @@ -328,7 +327,7 @@ def pull_event
match << '%' if ref
return match
elsif @source.match("ATTLIST", true)
md = @source.match(ATTLISTDECL_END, true)
md = @source.match(Private::ATTLISTDECL_END, true)
raise REXML::ParseException.new( "Bad ATTLIST declaration!", @source ) if md.nil?
element = md[1]
contents = md[0]
Expand Down Expand Up @@ -397,7 +396,7 @@ def pull_event
if @source.match("/", true)
@nsstack.shift
last_tag = @tags.pop
md = @source.match(CLOSE_PATTERN, true)
md = @source.match(Private::CLOSE_PATTERN, true)
if md and !last_tag
message = "Unexpected top-level end tag (got '#{md[1]}')"
raise REXML::ParseException.new(message, @source)
Expand Down Expand Up @@ -431,7 +430,7 @@ def pull_event
return process_instruction(start_position)
else
# Get the next tag
md = @source.match(TAG_PATTERN, true)
md = @source.match(Private::TAG_PATTERN, true)
unless md
@source.position = start_position
raise REXML::ParseException.new("malformed XML: missing tag start", @source)
Expand Down Expand Up @@ -539,7 +538,7 @@ def need_source_encoding_update?(xml_declaration_encoding)
end

def parse_name(base_error_message)
md = @source.match(NAME_PATTERN, true)
md = @source.match(Private::NAME_PATTERN, true)
unless md
if @source.match(/\s*\S/um)
message = "#{base_error_message}: invalid name"
Expand Down Expand Up @@ -618,7 +617,7 @@ def parse_id_invalid_details(accept_external_id:,
end

def process_instruction(start_position)
match_data = @source.match(INSTRUCTION_END, true)
match_data = @source.match(Private::INSTRUCTION_END, true)
unless match_data
message = "Invalid processing instruction node"
@source.position = start_position
Expand Down
1 change: 0 additions & 1 deletion lib/rexml/source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ module Private
end
end
private_constant :Private
include Private

# Constructor
# @param arg must be a String, and should be a valid XML document
Expand Down

0 comments on commit cfa8dd9

Please sign in to comment.