2009-09-25 Patrick Mueller <Patrick_Mueller@us.ibm.com>
Reviewed by Timothy Hatcher.
Content-type parameters not taken into account when building form-data
https://bugs.webkit.org/show_bug.cgi?id=28970
existing manual test case extended with new tests
* English.lproj/localizedStrings.js:
* inspector/front-end/ResourceView.js:
(WebInspector.ResourceView.prototype._refreshFormData):
(WebInspector.ResourceView.prototype._refreshParms):
* manual-tests/inspector/display-form-data.html:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48763 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index bfa469e..9655f54 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2009-09-25 Patrick Mueller <Patrick_Mueller@us.ibm.com>
+
+ Reviewed by Timothy Hatcher.
+
+ Content-type parameters not taken into account when building form-data
+ https://bugs.webkit.org/show_bug.cgi?id=28970
+
+ existing manual test case extended with new tests
+
+ * English.lproj/localizedStrings.js:
+ * inspector/front-end/ResourceView.js:
+ (WebInspector.ResourceView.prototype._refreshFormData):
+ (WebInspector.ResourceView.prototype._refreshParms):
+ * manual-tests/inspector/display-form-data.html:
+
2009-09-25 Yuan Song <song.yuan@ericsson.com>
Reviewed by Darin Adler.
diff --git a/WebCore/English.lproj/localizedStrings.js b/WebCore/English.lproj/localizedStrings.js
index 789948c..c53cd2f 100644
--- a/WebCore/English.lproj/localizedStrings.js
+++ b/WebCore/English.lproj/localizedStrings.js
Binary files differ
diff --git a/WebCore/inspector/front-end/ResourceView.js b/WebCore/inspector/front-end/ResourceView.js
index d915055..4fcc956 100644
--- a/WebCore/inspector/front-end/ResourceView.js
+++ b/WebCore/inspector/front-end/ResourceView.js
@@ -178,7 +178,7 @@
var isFormEncoded = false;
var requestContentType = this._getHeaderValue(this.resource.requestHeaders, "Content-Type");
- if (requestContentType == "application/x-www-form-urlencoded")
+ if (requestContentType.match(/^application\/x-www-form-urlencoded\s*(;.*)?$/i))
isFormEncoded = true;
if (isFormEncoded) {
@@ -217,14 +217,27 @@
for (var i = 0; i < parms.length; ++i) {
var key = parms[i][0];
- var val = parms[i][1];
+ var value = parms[i][1];
- if (val.indexOf("%") >= 0)
- if (this._decodeRequestParameters)
- val = decodeURIComponent(val).replace(/\+/g, " ");
+ var errorDecoding = false;
+ if (this._decodeRequestParameters) {
+ if (value.indexOf("%") >= 0) {
+ try {
+ value = decodeURIComponent(value);
+ } catch(e) {
+ errorDecoding = true;
+ }
+ }
+
+ value = value.replace(/\+/g, " ");
+ }
+
+ valueEscaped = value.escapeHTML();
+ if (errorDecoding)
+ valueEscaped += " <span class=\"error-message\">" + WebInspector.UIString("(unable to decode value)").escapeHTML() + "</span>";
var title = "<div class=\"header-name\">" + key.escapeHTML() + ":</div>";
- title += "<div class=\"header-value\">" + val.escapeHTML() + "</div>";
+ title += "<div class=\"header-value\">" + valueEscaped + "</div>";
var parmTreeElement = new TreeElement(title, null, false);
parmTreeElement.selectable = false;
diff --git a/WebCore/manual-tests/inspector/display-form-data.html b/WebCore/manual-tests/inspector/display-form-data.html
index 5f5b350..48cd817 100644
--- a/WebCore/manual-tests/inspector/display-form-data.html
+++ b/WebCore/manual-tests/inspector/display-form-data.html
@@ -1,4 +1,15 @@
-<p>Tests for <a href="https://bugs.webkit.org/show_bug.cgi?id=22920">Bug 22920: Inspector Request Headers Should Show Data/Variables/Parameters Sent With Request</a>
+<html>
+<head>
+<title>Tests for Bug 22920</title>
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
+</head>
+
+<body>
+<p>Tests for
+<ul>
+<li><p><a href="https://bugs.webkit.org/show_bug.cgi?id=22920">Bug 22920: Inspector Request Headers Should Show Data/Variables/Parameters Sent With Request</a>
+<li><p><a href="https://bugs.webkit.org/show_bug.cgi?id=28970">Bug 28970: content-type parameters not taken into account when building form-data</a>
+</ul>
<p>To test, open the Inspector on this page, go to the Resources panel,
and select the various resources created by this page in the left column of the
@@ -50,19 +61,44 @@
<br>Query String Parameters (2): "parm1: abc" and "parm2: d e f"
<br>Form Data (2): "parm1: ghi" and "parm2: j k l"
+<li><p><b>test-13</b>:
+<br>Query String Parameters (2): "parm1: äbc" and "parm2: d ě f"
+<br>Form Data (2): "parm1: ghi" and "parm2: j k l"
+<p>Note that you should view the encoded values of the query string parameters
+by double-clicking on one of the parameters. The values should be:
+<pre>
+parm1: %C3%A4bc
+parm2: d%20%C4%9B+f
+</pre>
+
+<li><p><b>test-14</b>:
+<br>Same results as for test-13, a slightly different but compatible Content-Type
+is used for the form data.
+
+<li><p><b>test-15</b>:
+<br>Query String Parameters (2): "parm1: % (unable to decode value)" and "parm2: % (unable to decode value)",
+with the parenthesized part in red.
+<br>Form Data (2): "parm1: % (unable to decode value)" and "parm2: % (unable to decode value)",
+with the parenthesized part in red.
+<p>Note that you should view the encoded values of the query string parameters
+by double-clicking on one of the parameters. The values for all four parameters should be "%".
+
<li><p><b>test-form</b>:
<br>For this test, invoke the form at the bottom of the page
by pressing the submit button. The Resources panel should have a "test-form"
resource, with the following data:
-<p>Form Data (2): "field1: value+a;b;c" and "field2:value+d;e;f"
-
+<p>Form Data (2): "field1: value ä;b;c" and "field2:value d;ě;f"
+<p>Note that you should view the encoded values of the query string parameters
+by double-clicking on one of the parameters. The values should be:
+<pre>
+field1: value+%C3%A4%3Bb%3Bc
+field2: value+d%3B%C4%9B%3Bf</pre>
</ul>
-<hr>
<p><b>test-form</b>
<form id="form" action="http://example.org/test-form" method="post" enctype="application/x-www-form-urlencoded">
-<input type="text" name="field1" value="value a;b;c">
-<input type="text" name="field2" value="value d;e;f">
+<span style="font-size:200%">field1:</span> <input style="font-size:200%" type="text" name="field1" value="value ä;b;c"><br>
+<span style="font-size:200%">field2:</span> <input style="font-size:200%" type="text" name="field2" value="value d;ě;f"><br>
<input type="submit">
</form>
@@ -74,6 +110,22 @@
</div>
+<hr>
+
+<p><b>NLS sample info</b>
+
+<pre>
+<span style="font-size:300%">ä</span> - LATIN SMALL LETTER A WITH DIAERESIS
+Unicode: 0x00E4 == 228
+UTF8: C3 A4
+HTML: &auml;
+
+<span style="font-size:300%">ě</span> - LATIN SMALL LETTER E WITH CARON
+Unicode: 0x011B == 283
+UTF8: C4 9B
+HTML: &#x11B;
+</pre>
+
<script>
function getReadyState(num) {
@@ -152,6 +204,14 @@
["Content-Type", "application/x-www-form-urlencoded"]
];
+var headersFormExtra1 = [
+ ["Content-Type", "application/x-www-form-urlencoded;something-else=here"]
+];
+
+var headersFormExtra2 = [
+ ["Content-Type", "application/x-www-form-urlencoded ; something-else=here"]
+];
+
var headersBinary = [
["Content-Type", "application/octet-stream"]
];
@@ -179,5 +239,11 @@
sendXHR("http://example.org/test-10^", "POST", headersForm, "parm1=abc");
sendXHR("http://example.org/test-11^", "POST", headersForm, "parm1=def&parm2=g%20h+i");
sendXHR("http://example.org/test-12^?parm1=abc&parm2=d%20e+f", "POST", headersForm, "parm1=ghi&parm2=j%20k+l");
+sendXHR("http://example.org/test-13^?parm1=%C3%A4bc&parm2=d%20%C4%9B+f", "POST", headersFormExtra1, "parm1=ghi&parm2=j%20k+l");
+sendXHR("http://example.org/test-14^?parm1=%C3%A4bc&parm2=d%20%C4%9B+f", "POST", headersFormExtra2, "parm1=ghi&parm2=j%20k+l");
+sendXHR("http://example.org/test-15^?parm1=%&parm2=%", "POST", headersForm, "parm1=%&parm2=%");
</script>
+
+</body>
+</html>
\ No newline at end of file