File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,8 @@ https://stackoverflow.com/questions/16452699/how-to-reset-a-form-using-jquery-wi
132132https://stackoverflow.com/questions/3955229/remove-all-child-elements-of-a-dom-node-in-javascript
133133https://stackoverflow.com/questions/11478324/syntaxerror-unexpected-eof-when-evaluating-javascript-in-ios-uiwebview
134134https://stackoverflow.com/questions/42053775/getting-error-form-submission-canceled-because-the-form-is-not-connected
135+ https://stackoverflow.com/questions/4467044/proper-way-to-catch-exception-from-json-parse
136+ https://stackoverflow.com/questions/29797946/handling-bad-json-parse-in-node-safely
135137
136138https://jquery.com/
137139http://youmightnotneedjquery.com/
Original file line number Diff line number Diff line change 7474
7575 interactive_one . stdoutFunction = function ( stdout ) {
7676 var target = document . getElementById ( 'instance-one-output' ) ;
77- var output = JSON . parse ( stdout ) ;
77+
78+ var output = null ;
79+ try {
80+ output = JSON . parse ( stdout ) ;
81+ } catch ( exception ) {
82+ return null ;
83+ }
84+
7885 var html ;
7986 if ( "user_input" in output ) {
8087 html = output . time + '<br>' + output . user_input ;
8188 } else {
8289 html = output . time ;
8390 } ;
91+
8492 target . innerHTML = html ;
8593 }
8694
103111
104112 interactive_two . stdoutFunction = function ( stdout ) {
105113 var target = document . getElementById ( 'instance-two-output' ) ;
106- var output = JSON . parse ( stdout ) ;
114+
115+ var output = null ;
116+ try {
117+ output = JSON . parse ( stdout ) ;
118+ } catch ( exception ) {
119+ return null ;
120+ }
121+
107122 var html ;
108123 if ( "user_input" in output ) {
109124 html = output . time + '<br>' + output . user_input ;
110125 } else {
111126 html = output . time ;
112127 } ;
128+
113129 target . innerHTML = html ;
114130 }
115131
You can’t perform that action at this time.
0 commit comments