Skip to content

Leading dot in TXT record chunk is stripped during record creation  #178

@zraly

Description

@zraly

Description

When trying to add a TXT record (for example for SPF) where one of the chunks starts with a dot, the library strips the leading dot during storage. The record is created in DNS, but the dot is missing, leading to invalid results. Example:

This input:

"v=spf1 ... include:spf.blueboard" ".cz -all"

Is written as (dot missing):

"v=spf1 ... include:spf.blueboardcz -all"

Expected: The chunk beginning with a dot should remain unchanged and the output should be:

"v=spf1 ... include:spf.blueboard" ".cz -all"

Investigation

I traced it to src/NetDNS2/Data.php#L79.

$value = trim($_data, '".')

This line will strip both quotes and all dots from both ends of the chunk value. For text chunks in TXT records, leading/trailing dots should be preserved, as they are valid characters (especially in SPF records or DKIM selectors).

Actual behavior

  • Leading dot is stripped, concatenating e.g. blueboard and cz into a single word, which is incorrect for SPF and other TXT usages.

Expected behavior

  • Leading dots in a chunk should be preserved for TXT record values, because they are semantically significant and required for valid DNS configuration.

Suggestion

  • The trim should not include dot (.) for TXT record values. Only quotes should be trimmed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions