Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 resolves #1493 fix global variable leak #1494

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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