BlogIntegrations · November 2, 2026 · 5 min read

Contact Form 7 URL-Encoded Payloads: Preserve Plus Signs, Ampersands and Spaces

Encode custom CF7 lead payloads once. Preserve literal plus signs, ampersands and Unicode while matching the receiver’s documented request format.

Plus and ampersand symbols travel between two inquiry cards through a transparent protective capsule.
Generated conceptual illustration; not a product screenshot or measured result.

A plus sign in an email address, an ampersand in an organization name and a space in a message can all be valid Contact Form 7 answers. They become unreliable when a custom integration builds an encoded request by joining raw strings. The receiver may interpret part of an answer as transport syntax.

The practical rule is to keep validated values unencoded inside the adapter, then serialize them once using the receiver’s documented format. This guide concerns custom outbound lead requests. It does not propose changing CF7’s own browser submission transport or claim that a plugin supplies a native connector.

Identify the boundary that actually uses form encoding

Read the destination endpoint documentation. Determine whether it expects JSON, multipart data or application/x-www-form-urlencoded. Record the method, required field names, accepted character encoding and multi-value representation. Those formats cannot be exchanged merely by changing a Content-Type header.

A JSON endpoint needs a JSON encoder and its documented schema. A form-encoded endpoint needs the corresponding serializer. Files may require multipart handling or a separate upload flow. Do not convert arbitrary file objects into text and assume the attachment survived.

Our URL parsing comparison addresses submitted website addresses. This is a different boundary: how several named answers become an outbound request body. Even a perfectly valid website or email value can be damaged by incorrect body encoding.

See why manual concatenation fails

The WHATWG URL Standard defines form-encoded parsing and serialization. In that representation, an ampersand separates pairs and a plus represents a space during parsing. A literal plus must therefore be encoded as data. Percent escapes also belong to the transport representation, rather than the original business answer.

Consider the synthetic organization Research & Support and reference A+B. Joining them into a body without a serializer can create an extra parameter and turn the plus into a space. The HTTP request can still succeed, leaving the team with altered records rather than an obvious transport error.

Do not repair this by replacing selected punctuation across the entire body. That mixes delimiters with values and usually misses a boundary case. The serializer needs the separate field names and values so it can protect their meaning.

Serialize raw values with URLSearchParams

For a JavaScript adapter using the standard API, pass values through methods instead of interpolating a prebuilt query string. The URLSearchParams reference explains why parsing an interpolated string can reinterpret literal plus signs. This small example performs no network request:

const body = new URLSearchParams();
body.append('organization', 'Research & Support');
body.append('reference', 'A+B');
body.append('message', 'Please call tomorrow');
const encoded = body.toString();
const decoded = new URLSearchParams(encoded);
console.assert(decoded.get('reference') === 'A+B');

The destination must still document the chosen keys and any repeated-value behavior. Appending the same name twice produces repeated pairs, but another server may expect bracketed names, a JSON array or a different convention. Test the receiver’s actual representation instead of assuming all form decoders agree.

Choose the PHP mode explicitly

In a PHP adapter, http_build_query() supports explicit encoding modes. Its default RFC1738 mode represents spaces with plus signs; RFC3986 mode uses percent-encoded spaces. Select the documented contract, specify the separator and inspect the resulting request in an isolated fixture.

$values = [
    'organization' => 'Research & Support',
    'reference' => 'A+B',
];
$encoded = http_build_query(
    $values, '', '&', PHP_QUERY_RFC1738
);

This example only builds a string. It does not register a CF7 hook or send a lead. If the maintained integration uses wp_remote_post(), review how its selected arguments construct the body. Decide whether the HTTP layer receives structured fields or an already serialized string. Do not encode the same values again in a second layer.

Detect double encoding and extra decoding

Use a synthetic literal such as %2B as well as an actual plus sign. They are different answers. Encoding the literal percent protects it for transport; decoding it twice later can incorrectly turn it into punctuation. Define which component owns serialization and which component owns decoding.

Keep that ownership visible in function names and adapter documentation. An upstream mapping function should return business values, not a mixture of raw and escaped strings. When reviewing a trace, label a value as raw, encoded body or receiver-decoded data so reviewers do not compare incompatible representations.

Verify the full round trip with fictional answers

Use a local decoder or approved staging receiver. Include a plus-tagged fictional address, an ampersand, an equals sign, percent text, a blank value, an accented name and a multiline message. Compare decoded values exactly with the intended inputs before any business normalization runs.

Also check omitted fields and repeated names. Transport preservation does not decide whether an empty answer should clear an existing CRM property. Our missing and empty update guide covers that later policy. For encoded size limits, measure the actual serialized body, using the payload byte-size guide as a starting point.

Finish with separate acceptance evidence

A faithful round trip proves a narrow encoding behavior. It does not prove the destination accepted the lead, assigned the correct owner or completed a later workflow. Inspect the documented response and resulting synthetic record before calling the handoff verified. Keep production message contents out of routine diagnostics.

For WordPress submission statistics, review our free Svetlik Analytics for Contact Form 7. Its reporting is separate from the custom adapter described here. Preserve answers through serialization first, then verify each downstream outcome on its own evidence.