Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: src/json.js

Issue 3349006: Fix bug in JSON character quote table. (Closed)
Patch Set: Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 } 68 }
69 69
70 var characterQuoteCache = { 70 var characterQuoteCache = {
71 '\b': '\\b', // ASCII 8, Backspace 71 '\b': '\\b', // ASCII 8, Backspace
72 '\t': '\\t', // ASCII 9, Tab 72 '\t': '\\t', // ASCII 9, Tab
73 '\n': '\\n', // ASCII 10, Newline 73 '\n': '\\n', // ASCII 10, Newline
74 '\f': '\\f', // ASCII 12, Formfeed 74 '\f': '\\f', // ASCII 12, Formfeed
75 '\r': '\\r', // ASCII 13, Carriage Return 75 '\r': '\\r', // ASCII 13, Carriage Return
76 '\"': '\\"', 76 '\"': '\\"',
77 '/': '\\/' 77 '\\': '\\\\'
78 }; 78 };
79 79
80 function QuoteSingleJSONCharacter(c) { 80 function QuoteSingleJSONCharacter(c) {
81 if (c in characterQuoteCache) { 81 if (c in characterQuoteCache) {
82 return characterQuoteCache[c]; 82 return characterQuoteCache[c];
83 } 83 }
84 var charCode = c.charCodeAt(0); 84 var charCode = c.charCodeAt(0);
85 var result; 85 var result;
86 if (charCode < 16) result = '\\u000'; 86 if (charCode < 16) result = '\\u000';
87 else if (charCode < 256) result = '\\u00'; 87 else if (charCode < 256) result = '\\u00';
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 } 257 }
258 258
259 function SetupJSON() { 259 function SetupJSON() {
260 InstallFunctions($JSON, DONT_ENUM, $Array( 260 InstallFunctions($JSON, DONT_ENUM, $Array(
261 "parse", JSONParse, 261 "parse", JSONParse,
262 "stringify", JSONStringify 262 "stringify", JSONStringify
263 )); 263 ));
264 } 264 }
265 265
266 SetupJSON(); 266 SetupJSON();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698