Skip to content

Access to "raw" strings in NAPTR record #404

@MMauro94

Description

@MMauro94

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions