#define DNS_NAME_OMITFINALDOT 0x01U
#define DNS_NAME_PRINCIPAL 0x02U /* do not escape $ and @ */
+#define DNS_NAME_QUOTED 0x04U /* minimal escaping within double quotes */
isc_result_t
dns_name_totext(const dns_name_t *name, unsigned int options,
bool
dns_name_ishostname(const dns_name_t *name, bool wildcard);
/*%<
- * Return if 'name' is a valid hostname. RFC 952 / RFC 1123.
+ * Return true if 'name' is a valid hostname. RFC 952 / RFC 1123.
* If 'wildcard' is true then allow the first label of name to
* be a wildcard.
* The root is also accepted.
bool
dns_name_ismailbox(const dns_name_t *name);
/*%<
- * Return if 'name' is a valid mailbox. RFC 821.
+ * Return true if 'name' is a valid mailbox. RFC 821.
*
* Requires:
* \li 'name' to be valid.
bool
dns_name_internalwildcard(const dns_name_t *name);
/*%<
- * Return if 'name' contains a internal wildcard name.
+ * Return true if 'name' contains a internal wildcard name.
*
* Requires:
* \li 'name' to be valid.
bool saw_root = false;
unsigned int oused;
bool omit_final_dot = ((options & DNS_NAME_OMITFINALDOT) != 0);
+ bool minimal = ((options & DNS_NAME_QUOTED) != 0);
+ bool principal = ((options & DNS_NAME_PRINCIPAL) != 0);
bool first = true;
/*
/* Special modifiers in zone files. */
case 0x40: /* '@' */
case 0x24: /* '$' */
- if ((options & DNS_NAME_PRINCIPAL) != 0)
- {
+ if (principal) {
goto no_escape;
}
FALLTHROUGH;
- case 0x22: /* '"' */
case 0x28: /* '(' */
case 0x29: /* ')' */
- case 0x2E: /* '.' */
case 0x3B: /* ';' */
+ if (minimal) {
+ goto no_escape;
+ }
+ FALLTHROUGH;
+ case 0x22: /* '"' */
+ case 0x2E: /* '.' */
case 0x5C: /* '\\' */
value = '\\' << 8 | c;
CHECK(isc_buffer_reserve(target, 2));
break;
no_escape:
default:
- if (c > 0x20 && c < 0x7f) {
+ if ((c > 0x20 && c < 0x7f) ||
+ (c == 0x20 && minimal))
+ {
CHECK(isc_buffer_reserve(target,
1));
isc_buffer_putuint8(target, c);