Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TXT records without quotation marks ignore content after first whitespace #116

Open
tquensen opened this issue Apr 19, 2023 · 1 comment

Comments

@tquensen
Copy link

tquensen commented Apr 19, 2023

For a TXT record like example.org. TXT 300 v=spf1 mx include:spf.example.com -all the parser ignores the content after the first space.

TXT records are allowed to have multiple "character strings" so this behaviour is valid

I replaced the fromText method to resolve the issue. This also fixes content with multiple quoted strings, like "foo bar" "foo baz"

public function fromText(string $text): void
			{
				$string = new StringIterator($text);
				$txt = new StringIterator();

				while ($string->valid()) {
					if ($string->is(static::WHITESPACE)) {
						$string->next();
						continue;
					}

					if ($string->is(Tokens::DOUBLE_QUOTES)) {
						self::handleTxt($string, $txt);
						$string->next();
						$txt->append(' ');
						continue;
					}

					static::handleContiguousString($string, $txt);
					$string->next();
					$txt->append(' ');
				}

				$this->setText(trim((string) $txt), true);
			}
Spirit55555 added a commit to Spirit55555/DNS that referenced this issue Jun 2, 2024
@samuelwilliams
Copy link
Contributor

What test cases need to be added?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants