Skip to content

Commit 0f507b2

Browse files
Merge pull request #768 from ossf/remove_yaml_lib
Remove YAML processing library
2 parents e6df417 + ffc2d8a commit 0f507b2

22 files changed

+10
-55
lines changed

docs/labs/argument-injection.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="argument-injection.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/assert.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="assert.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/checker.js

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -598,30 +598,10 @@ function processHints(requestedHints) {
598598
return compiledHints;
599599
}
600600

601-
/** Load and parse YAML data, return result to be placed in "info".
602-
* @info: String with YAML (including JSON) data to use
603-
*/
604-
function processYamlToInfo(configurationInfo) {
605-
// This would only allow JSON, but then we don't need to load YAML lib:
606-
// let parsedJson = JSON.parse(configurationInfo);
607-
608-
let parsedData; // Parsed data, *if* we manage to parse it.
609-
try {
610-
parsedData = jsyaml.load(configurationInfo);
611-
}
612-
catch (e) {
613-
showDebugOutput(
614-
`Lab Error: Cannot process YAML of info.\n${e}`);
615-
throw e; // Rethrow, so containing browser also gets exception
616-
}
617-
618-
return parsedData;
619-
}
620-
621601
/** Set global values based on other than "correct" and "expected" values.
622602
* The correct and expected values may come from elsewhere, but we have to set up the
623603
* info-based values first, because info can change how those are interpreted.
624-
* @info: String with YAML (including JSON) data to use
604+
* @configurationInfo: Data to use
625605
*/
626606
function processInfo(configurationInfo) {
627607
const allowedInfoFields = new Set([
@@ -746,17 +726,12 @@ function runSelftest() {
746726
* The "info" data includes the regex preprocessing steps, hints, etc.
747727
*/
748728
function setupInfo() {
749-
// We must load info *first*, because it can affect how other things
750-
// (like pattern preprocessing) is handled.
751-
752-
// Deprecated approach: Load embedded "info" data in YAML file.
753-
// If there is "info" data embedded in the HTML (e.g., hints),
754-
// load it & set up global variable hints.
755-
let infoElement = document.getElementById('info');
756-
if (infoElement) {
757-
let configurationYamlText = infoElement.textContent;
758-
// Set global variable "info"
759-
info = processYamlToInfo(configurationYamlText);
729+
// We no longer need a *separate* step to load info, we presume the
730+
// HTML loaded it.
731+
// As a safety check, let's make sure some data *was* loaded.
732+
733+
if (Object.keys(info).length == 0) {
734+
alert(`ERROR: info has no values set. Load/modify your lab .js file.`);
760735
};
761736

762737
// If an "info2" exists, report any differences between it and "info".
@@ -768,7 +743,6 @@ function setupInfo() {
768743
}
769744
};
770745

771-
772746
// Set global values *except* correct and expected arrays
773747
processInfo(info);
774748

@@ -830,8 +804,10 @@ function initPage() {
830804
attempt.oninput = runCheck;
831805
current++;
832806
}
833-
for (let hintButton of document.querySelectorAll("button.hintButton")) {
807+
for (let hintButton of document.querySelectorAll("button.hintButton")){
834808
hintButton.addEventListener('click', (e) => { showHint(e); });
809+
// Precompute inputIndexes to work around problems that occur
810+
// if a user uses a browser's built-in natural language translation.
835811
// Presumes button's parent is the form
836812
hintButton.dataset.inputIndexes = findIndexes(hintButton.parentNode);
837813
if (!hintButton.title) {

docs/labs/conversion.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="conversion.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/csp1.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="csp1.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/deserialization.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="deserialization.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/format-strings.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="format-strings.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/free.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="free.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/handling-errors.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="handling-errors.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

docs/labs/hardcoded.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1">
66
<link rel="stylesheet" href="https://best.openssf.org/assets/css/style.css">
77
<link rel="stylesheet" href="checker.css">
8-
<script src="js-yaml.min.js"></script>
98
<script src="checker.js"></script>
109
<script src="hardcoded.js"></script>
1110
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

0 commit comments

Comments
 (0)