Repository: jquery/jquery
File: test/unit/ajax.js (JavaScript)

Code before:
			url: "bogus.html",
			data: { devo: "A Beautiful World" },
			type: "post",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "devo=A+Beautiful+World", "data is '+'-encoded" );
				return false;
			},
			error: true
		};
	} );

	ajaxTest( "jQuery.ajax() - data - text/plain (gh-2658)", 1, function( assert ) {
		return {
			url: "bogus.html",
			data: { devo: "A Beautiful World" },
			type: "post",
			contentType: "text/plain",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "devo=A%20Beautiful%20World", "data is %20-encoded" );
				return false;
			},
			error: true
		};
	} );

	ajaxTest( "jQuery.ajax() - don't escape %20 in contentType (gh-4119)", 1, function( assert ) {
		return {
			url: "bogus.html",
			contentType: "application/x-www-form-urlencoded",
			headers: { "content-type": "application/json" },
			method: "post",
			dataType: "json",
			data: "{\"val\":\"%20\"}",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "{\"val\":\"%20\"}", "data is not %20-encoded" );
				return false;
			},
			error: true
		};
	} );

	ajaxTest( "jQuery.ajax() - data - no processing POST", 1, function( assert ) {
		return {
			url: "bogus.html",
			data: { devo: "A Beautiful World" },
			type: "post",
			contentType: "x-special-sauce",
			processData: false,
			beforeSend: function( _, s ) {
				assert.deepEqual( s.data, { devo: "A Beautiful World" }, "data is not processed" );
				return false;

Review comment (suggestion):
We weren't escaping `%20` in contentType but in data. How about:
```suggestion
	ajaxTest( "jQuery.ajax() - '%20' in data with a header Content-Type override (gh-4119)", 1, function( assert ) {
```
? A bit long but I don't have shorter ideas at the moment.

Code after:
			url: "bogus.html",
			data: { devo: "A Beautiful World" },
			type: "post",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "devo=A+Beautiful+World", "data is '+'-encoded" );
				return false;
			},
			error: true
		};
	} );

	ajaxTest( "jQuery.ajax() - data - text/plain (gh-2658)", 1, function( assert ) {
		return {
			url: "bogus.html",
			data: { devo: "A Beautiful World" },
			type: "post",
			contentType: "text/plain",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "devo=A%20Beautiful%20World", "data is %20-encoded" );
				return false;
			},
			error: true
		};
	} );

	ajaxTest( "jQuery.ajax() - don't escape %20 with contentType override (gh-4119)", 1, function( assert ) {
		return {
			url: "bogus.html",
			contentType: "application/x-www-form-urlencoded",
			headers: { "content-type": "application/json" },
			method: "post",
			dataType: "json",
			data: "{\"val\":\"%20\"}",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "{\"val\":\"%20\"}", "data is not %20-encoded" );
				return false;
			},
			error: true
		};
	} );

	ajaxTest( "jQuery.ajax() - escape %20 with contentType override (gh-4119)", 1, function( assert ) {
		return {
			url: "bogus.html",
			contentType: "application/json",
			headers: { "content-type": "application/x-www-form-urlencoded" },
			method: "post",
			dataType: "json",
			data: "{\"val\":\"%20\"}",
			beforeSend: function( _, s ) {
				assert.strictEqual( s.data, "{\"val\":\"+\"}", "data is %20-encoded" );