Skip to content

Commit

Permalink
Fix uninitialized constant error by requiring lib/security.rb in lib/…
Browse files Browse the repository at this point in the history
…parsers/baseparser.rb

This commit fixes an issue in `REXML::Parsers::BaseParser`
where the `Security` module is not initialized, causing a NameError.

How to reproduce

When `lib/rexml/parsers/baseparser.rb` is loaded directly,
the `Security` module is not required, leading to the following error.

```ruby
require_relative "./lib/rexml/parsers/baseparser"

pp REXML::Security.name
```
```console
$ ruby test.rb
test.rb:3:in `<main>': uninitialized constant REXML::Security (NameError)

pp REXML::Security.name
        ^^^^^^^^^^
Did you mean?  SecurityError
```

How to resolve

Require `Security` module in `lib/rexml/parsers/baseparser.rb` to
ensure the `Security` module is initialized when `BaseParser` is loaded.
  • Loading branch information
otegami committed Aug 1, 2024
1 parent d65e27c commit 34e764c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/rexml/parsers/baseparser.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true
require_relative '../parseexception'
require_relative '../undefinednamespaceexception'
require_relative '../security'
require_relative '../source'
require 'set'
require "strscan"
Expand Down

0 comments on commit 34e764c

Please sign in to comment.