-
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split_txt: add method to split txt records as per RFC 4408
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# @summary function to split TXT records. Long TXT records must be broken into strings of 255 characters as per RFC 4408 | ||
# @param data A TXT record to split | ||
# @return A string of 255 character strings | ||
function unbound::split_txt( | ||
String[1] $data | ||
) >> String[1] { | ||
$data.slice(255).map |$slice| { "\"${slice.join}\"" }.join | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
input = "Long TXT Record #{'X' * 255}" | ||
output = "\"Long TXT Record #{'X' * 239}\"\"#{'X' * 16}\"" | ||
|
||
describe 'unbound::split_txt' do | ||
it { is_expected.to run.with_params(input).and_return(output) } | ||
end |