Download tasks/codeql_javascript_benchmark_top30_v1/morefixes-bd86b40955cabdb21c65/patch.diff from Benchanything/checkerbench: direct link, hf CLI and curl.
- Browser
- Download file 1.87 kB
-
https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_javascript_benchmark_top30_v1/morefixes-bd86b40955cabdb21c65/patch.diff
- Command line
-
hf download hf://datasets/Benchanything/checkerbench/tasks/codeql_javascript_benchmark_top30_v1/morefixes-bd86b40955cabdb21c65/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/Benchanything/checkerbench/resolve/main/tasks/codeql_javascript_benchmark_top30_v1/morefixes-bd86b40955cabdb21c65/patch.diff
1.87 kB
| diff --git a/lib/grunt/file.js b/lib/grunt/file.js | |
| index eefeddb..7e0e2fb 100644 | |
| --- a/lib/grunt/file.js | |
| +++ b/lib/grunt/file.js | |
| file.readJSON = function(filepath, options) { | |
| }; | |
| // Read a YAML file, parse its contents, return an object. | |
| -file.readYAML = function(filepath, options) { | |
| +file.readYAML = function(filepath, options, yamlOptions) { | |
| + if (!options) { options = {}; } | |
| + if (!yamlOptions) { yamlOptions = {}; } | |
| + | |
| var src = file.read(filepath, options); | |
| var result; | |
| grunt.verbose.write('Parsing ' + filepath + '...'); | |
| try { | |
| - result = YAML.load(src); | |
| + // use the recommended way of reading YAML files | |
| + // https://github.com/nodeca/js-yaml#safeload-string---options- | |
| + if (yamlOptions.unsafeLoad) { | |
| + result = YAML.load(src); | |
| + } else { | |
| + result = YAML.safeLoad(src); | |
| + } | |
| grunt.verbose.ok(); | |
| return result; | |
| } catch (e) { | |
| diff --git a/test/grunt/file_test.js b/test/grunt/file_test.js | |
| index e833fb2..b192cad 100644 | |
| --- a/test/grunt/file_test.js | |
| +++ b/test/grunt/file_test.js | |
| exports.file = { | |
| test.done(); | |
| }, | |
| 'readYAML': function(test) { | |
| - test.expect(4); | |
| + test.expect(5); | |
| var obj; | |
| obj = grunt.file.readYAML('test/fixtures/utf8.yaml'); | |
| - test.deepEqual(obj, this.object, 'file should be read as utf8 by default and parsed correctly.'); | |
| + test.deepEqual(obj, this.object, 'file should be safely read as utf8 by default and parsed correctly.'); | |
| + | |
| + obj = grunt.file.readYAML('test/fixtures/utf8.yaml', null, {unsafeLoad: true}); | |
| + test.deepEqual(obj, this.object, 'file should be unsafely read as utf8 by default and parsed correctly.'); | |
| obj = grunt.file.readYAML('test/fixtures/iso-8859-1.yaml', {encoding: 'iso-8859-1'}); | |
| test.deepEqual(obj, this.object, 'file should be read using the specified encoding.'); | |