Skip to content

Commit

Permalink
Merge pull request #1089 from Mogztter/fix-asciidoctor-upstream-3766
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrossetie authored Oct 29, 2020
2 parents 1996a3b + ad7791b commit 4e5ee5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class AbstractNode
def read_contents target, opts = {}
doc = @document
if (Helpers.uriish? target) || ((start = opts[:start]) && (Helpers.uriish? start) && (target = doc.path_resolver.web_path target, start))
if (doc.path_resolver.descends_from? target, doc.base_dir) || (doc.attr? 'allow-uri-read')
if (doc.path_resolver.descends_from? target, doc.base_dir) || (target.start_with? 'chrome://') || (doc.attr? 'allow-uri-read')
begin
if opts[:normalize]
(Helpers.prepare_source_string ::File.read(target)).join LF
Expand Down
15 changes: 13 additions & 2 deletions packages/core/spec/browser/asciidoctor-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,24 @@ import Asciidoctor from '../../build/asciidoctor-browser.js'
standalone: true,
attributes
}
const defaultLogger = asciidoctor.LoggerManager.getLogger()
const memoryLogger = asciidoctor.MemoryLogger.create()
try {
asciidoctor.LoggerManager.setLogger(memoryLogger)
asciidoctor.convert('Hello world', options)
expect.fail('the resource does not exist and the converter should throw an exception!')
const errorMessage = memoryLogger.getMessages()[0]
expect(errorMessage.getSeverity()).to.equal('WARN')
expect(errorMessage.getText()).to.include('could not retrieve contents of stylesheet at URI: chrome://asciidoctor/extension/css/asciidoctor-plus.css')
} catch (e) {
// the resource does not exist but chrome:// is a root path and should not be prepended by "./"
// we expect the processor to try to load the resource 'chrome://asciidoctor/extension/css/asciidoctor-plus.css' and fail!
expect(e.message).to.include('Failed to load \'chrome://asciidoctor/extension/css/asciidoctor-plus.css\'')
if (asciidoctorCoreSemVer.lte('2.0.10')) {
expect(e.message).to.include('Failed to load \'chrome://asciidoctor/extension/css/asciidoctor-plus.css\'')
} else {
throw e
}
} finally {
asciidoctor.LoggerManager.setLogger(defaultLogger)
}
})
})
Expand Down
1 change: 1 addition & 0 deletions packages/core/spec/share/asciidoctor-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ paragraph 3
doctype: 'article',
safe: 'unsafe',
header_footer: true,
base_dir: testOptions.baseDir,
attributes: ['showtitle', 'stylesheet=asciidoctor.css', 'stylesdir=' + testOptions.baseDir + '/build/css']
}
const html = asciidoctor.convert('=== Test', options)
Expand Down

0 comments on commit 4e5ee5f

Please sign in to comment.