|
305 | 305 | if (!is_numeric($data['idx'])) fatalerr('Invalid webauthn request'); |
306 | 306 | $keys = json_decode(query_setting('webauthnkeys', '[]', true)); |
307 | 307 | array_splice($keys, $data['idx'], 1); |
308 | | - store_setting('webauthnkeys', json_encode($keys)); |
| 308 | + store_setting('webauthnkeys', json_encode($keys, JSON_THROW_ON_ERROR)); |
309 | 309 | foreach ($keys as $key) { |
310 | 310 | $ret[] = $key['name'] ?? dechex(crc32(implode('', $key->id))); |
311 | 311 | } |
@@ -805,7 +805,7 @@ function($row) use ($note) { |
805 | 805 |
|
806 | 806 | if (!($stmt->execute([ $note['content'], $note['title'], $pinned, $cursor, $note['mode'] ?? 'edit', $id ]))) { |
807 | 807 | $processUser = posix_getpwuid(posix_geteuid()); |
808 | | - error_log("update_note() update execute failed: " . $stmt->errorInfo()[2] . ' (userid: ' . json_encode($processUser) . ')'); |
| 808 | + error_log("update_note() update execute failed: " . $stmt->errorInfo()[2] . ' (userid: ' . json_encode($processUser, JSON_THROW_ON_ERROR) . ')'); |
809 | 809 | return []; |
810 | 810 | } |
811 | 811 |
|
@@ -907,7 +907,7 @@ function update_note_meta($id, $note) { |
907 | 907 | } |
908 | 908 | if (!($stmt->execute([ $pinned, $cursor, $note['mode'] ?? 'edit', $id ]))) { |
909 | 909 | $processUser = posix_getpwuid(posix_geteuid()); |
910 | | - error_log("FlowNotes: update_note_meta() update execute failed: " . $stmt->errorInfo()[2] . ' (userid: ' . json_encode($processUser) . ')'); |
| 910 | + error_log("FlowNotes: update_note_meta() update execute failed: " . $stmt->errorInfo()[2] . ' (userid: ' . json_encode($processUser, JSON_THROW_ON_ERROR) . ')'); |
911 | 911 | return 0; |
912 | 912 | } |
913 | 913 | return $pinned; |
@@ -1156,12 +1156,13 @@ function sql_updatecount($query, $params = []) { |
1156 | 1156 |
|
1157 | 1157 | function send_and_exit($data) { |
1158 | 1158 | header('Content-type: application/json'); |
1159 | | - print json_encode($data); |
| 1159 | + print json_encode($data, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_INVALID_UTF8_SUBSTITUTE); |
| 1160 | + if (json_last_error()) error_log('FlowNotes JSON encode error: ' . json_last_error_msg()); |
1160 | 1161 | exit(); |
1161 | 1162 | } |
1162 | 1163 | function fatalerr($msg) { |
1163 | 1164 | header('Content-type: application/json'); |
1164 | | - print json_encode([ 'error' => $msg ]); |
| 1165 | + print json_encode([ 'error' => $msg ], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_INVALID_UTF8_SUBSTITUTE|JSON_THROW_ON_ERROR); |
1165 | 1166 | exit(1); |
1166 | 1167 | } |
1167 | 1168 | function dbg($var) { |
|
0 commit comments