Hello :)
I'm on a quest to parse NAPTR's regexp field as per RFC 3402, section 3.2.
I'm partially stuck because the getRegexp function converts the bytes to string via byteArrayToString: this adds back the escape character (\) where needed for string representation.
However, to correctly parse the regexp field, I would need the underlying unescaped value of this field.
For instance, if the regexp field was !a\!b!c!i I would have to parse:
- delim:
!
- ere:
a!b
- repl:
c
- flags:
i
However, in textual representation, \ itself would have to be escaped, e.g.:
val naptr = Record.fromString(Name.fromConstantString("example.com"), Type.NAPTR, DClass.IN, """!a\\!b!c!i""", Name.root) as NAPTRRecord
naptr.getRegexp() // returns the string "!a\\!b!c!i"
There is currently no way to access the raw bytes of the regexp field. However, this is possible for TXT records using getStringsAsByteArrays.
Would it be possible to introduce a getRegexpAsByteArray function that simply exposes the underlying regexp field? The same could be done for flags and service.
Would a PR that adds this be accepted?
Hello :)
I'm on a quest to parse NAPTR's
regexpfield as per RFC 3402, section 3.2.I'm partially stuck because the
getRegexpfunction converts the bytes to string viabyteArrayToString: this adds back the escape character (\) where needed for string representation.However, to correctly parse the
regexpfield, I would need the underlying unescaped value of this field.For instance, if the regexp field was
!a\!b!c!iI would have to parse:!a!bciHowever, in textual representation,
\itself would have to be escaped, e.g.:There is currently no way to access the raw bytes of the
regexpfield. However, this is possible for TXT records usinggetStringsAsByteArrays.Would it be possible to introduce a
getRegexpAsByteArrayfunction that simply exposes the underlyingregexpfield? The same could be done for flags and service.Would a PR that adds this be accepted?