Skip to content

Commit

Permalink
resolves #1493 fix global variable leak
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux committed Dec 7, 2021
1 parent da3acd2 commit 208b4ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Bug Fixes::
* Invoke `LoggerManager#setLogger` setter - thanks @mojavelinux (#1322)
* Strip alternate BOM that uses char code 65279 when input passes through a Buffer - thanks @mojavelinux (#1344)
* Properly cache the helpers file in the template converter - thanks @yGuy (#1373)
* Fix global variable leak (#1493)

Improvements::

Expand Down
7 changes: 7 additions & 0 deletions packages/core/lib/asciidoctor/js/asciidoctor_ext/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ def fill_datetime_attributes attrs, input_mtime
var nil = Opal.nil
var utc_offset
var source_date_epoch
var localdate
var localyear
var localtime
var localdatetime
var docdate
var doctime
var getYear = function (time, utc_offset) {
return utc_offset === 0 ? time.getUTCFullYear() : time.getFullYear()
Expand Down Expand Up @@ -95,6 +101,7 @@ def fill_datetime_attributes attrs, input_mtime
var mtime_hours = ('0' + (getHours(input_mtime, utc_offset))).slice(-2)
var mtime_minutes = ('0' + (input_mtime.getMinutes())).slice(-2)
var mtime_seconds = ('0' + (input_mtime.getSeconds())).slice(-2)
var utc_offset_format
if (utc_offset === 0) {
utc_offset_format = 'UTC'
} else if (utc_offset > 0) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/spec/node/asciidoctor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@ intro
it('should be able to load a file', () => {
const doc = asciidoctor.loadFile(resolveFixture('test.adoc'))
expect(doc.getAttribute('docname')).to.equal('test')
expect(global.localdatetime).to.be.undefined()
})

it('should be able to load a buffer', () => {
Expand Down

0 comments on commit 208b4ca

Please sign in to comment.