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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkLogView.js

Issue 2182213006: [Devtools] Fix multi-line curl copy response when multi-part-form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed windows curl with multi-line Created 4 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org> 3 * Copyright (C) 2008, 2009 Anthony Ricaud <rik@webkit.org>
4 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 * @return {string} 1356 * @return {string}
1357 */ 1357 */
1358 _generateCurlCommand: function(request, platform) 1358 _generateCurlCommand: function(request, platform)
1359 { 1359 {
1360 var command = ["curl"]; 1360 var command = ["curl"];
1361 // These headers are derived from URL (except "version") and would be ad ded by cURL anyway. 1361 // These headers are derived from URL (except "version") and would be ad ded by cURL anyway.
1362 var ignoredHeaders = {"host": 1, "method": 1, "path": 1, "scheme": 1, "v ersion": 1}; 1362 var ignoredHeaders = {"host": 1, "method": 1, "path": 1, "scheme": 1, "v ersion": 1};
1363 1363
1364 function escapeStringWin(str) 1364 function escapeStringWin(str)
1365 { 1365 {
1366 /* Replace quote by double quote (but not by \") because it is 1366 /* If there are no new line characters do not escape the " character s
1367 recognized by both cmd.exe and MS Crt arguments parser. 1367 since it only uglifies the command.
1368 1368
1369 Replace % by "%" because it could be expanded to an environment 1369 Because cmd.exe parser and MS Crt arguments parsers use some of t he
1370 variable value. So %% becomes "%""%". Even if an env variable "" 1370 same escape characters, they can interact with each other in
1371 (2 doublequotes) is declared, the cmd.exe will not 1371 horrible ways, the order of operations is critical.
1372 substitute it with its value.
1373 1372
1374 Replace each backslash with double backslash to make sure 1373 Replace \ with \\ first because it is an escape character for cer tain
1375 MS Crt arguments parser won't collapse them. 1374 conditions in both parsers.
1376 1375
1377 Replace new line outside of quotes since cmd.exe doesn't let 1376 Replace all " with \" to ensure the first parser does not remove it.
1378 to do it inside. 1377
1378 Then escape all characters we are not sure about with ^ to ensure it
1379 gets to MS Crt parser safely.
1380
1381 The % character is special because MS Crt parser will try and loo k for
1382 ENV variables and fill them in it's place. We cannot escape them with %
1383 and cannot escape them with ^ (because it's cmd.exe's escape not MS Crt
1384 parser); So we can get cmd.exe parser to escape the character aft er it,
1385 if it is followed by a valid beginning character of an ENV variab le.
1386 This ensures we do not try and double escape another ^ if it was placed
1387 by the previous replace.
1388
1389 Lastly we replace new lines with ^ and TWO new lines because the first
1390 new line is there to enact the escape command the second is the c haracter
1391 to escape (in this case new line).
1379 */ 1392 */
1380 return "\"" + str.replace(/"/g, "\"\"") 1393 var encapsChars = /[\r\n]/.test(str) ? "^\"" : "\"";
1381 .replace(/%/g, "\"%\"") 1394 return encapsChars + str.replace(/\\/g, "\\\\")
1382 .replace(/\\/g, "\\\\") 1395 .replace(/"/g, "\\\"")
1383 .replace(/[\r\n]+/g, "\"^$&\"") + "\""; 1396 .replace(/[^a-zA-Z0-9\s_\-:=+~'\/.',?;()*`]/g, "^$& ")
1397 .replace(/%(?=[a-zA-Z0-9_])/g, "%^")
1398 .replace(/\r\n|[\n\r]/g, "^\n\n") + encapsChars;
1384 } 1399 }
1385 1400
1386 function escapeStringPosix(str) 1401 function escapeStringPosix(str)
1387 { 1402 {
1388 function escapeCharacter(x) 1403 function escapeCharacter(x)
1389 { 1404 {
1390 var code = x.charCodeAt(0); 1405 var code = x.charCodeAt(0);
1391 if (code < 256) { 1406 if (code < 256) {
1392 // Add leading zero when needed to not care about the next c haracter. 1407 // Add leading zero when needed to not care about the next c haracter.
1393 return code < 16 ? "\\x0" + code.toString(16) : "\\x" + code .toString(16); 1408 return code < 16 ? "\\x0" + code.toString(16) : "\\x" + code .toString(16);
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 return false; 1703 return false;
1689 return true; 1704 return true;
1690 } 1705 }
1691 1706
1692 WebInspector.NetworkLogView.EventTypes = { 1707 WebInspector.NetworkLogView.EventTypes = {
1693 RequestSelected: "RequestSelected", 1708 RequestSelected: "RequestSelected",
1694 SearchCountUpdated: "SearchCountUpdated", 1709 SearchCountUpdated: "SearchCountUpdated",
1695 SearchIndexUpdated: "SearchIndexUpdated", 1710 SearchIndexUpdated: "SearchIndexUpdated",
1696 UpdateRequest: "UpdateRequest" 1711 UpdateRequest: "UpdateRequest"
1697 }; 1712 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698