diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index c6f3bc47d..524939508 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -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:: diff --git a/packages/core/lib/asciidoctor/js/asciidoctor_ext/document.rb b/packages/core/lib/asciidoctor/js/asciidoctor_ext/document.rb index 72fa9ab33..d5c06194d 100644 --- a/packages/core/lib/asciidoctor/js/asciidoctor_ext/document.rb +++ b/packages/core/lib/asciidoctor/js/asciidoctor_ext/document.rb @@ -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() @@ -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) { diff --git a/packages/core/spec/node/asciidoctor.spec.js b/packages/core/spec/node/asciidoctor.spec.js index 61980c896..9548837b4 100644 --- a/packages/core/spec/node/asciidoctor.spec.js +++ b/packages/core/spec/node/asciidoctor.spec.js @@ -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', () => {