Subject: [netmod] chars that require quoting

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 29 Jan 2016 11:12:59 +0100

Hi,

I think the following change to sec. 6.1.3 of 6020bis is needed:

OLD
   If a string contains any space or tab characters, a semicolon (";"),
   braces ("{" or "}"), or comment sequences ("//", "/*", or "*/"), then
   it MUST be enclosed within double or single quotes.

NEW
   If a string contains any space, tab or newline characters, a semicolon (";"),
   braces ("{" or "}"), or comment sequences ("//", "/*", or "*/"), then
   it MUST be enclosed within double or single quotes.

And what about the CR character and single or double quotes? This seems to be legal and results in a description argument of length 5 (in pyang at least):

description \"hi";

I am not sure it is a good idea to permit this though.

Lada

--
Ladislav Lhotka, CZ.NIC Labs
PGP Key ID: E74E8C0C

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 29 Jan 2016 12:55:04 +0100 (CET)

>    it MUST be enclosed within double or single quotes.

I agree.

> And what about the CR character and single or double quotes? This
> seems to be legal and results in a description argument of length 5
> (in pyang at least):
> 
> description \"hi";

I don't understand what you mean.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 29 Jan 2016 13:14:27 +0100

> On 29 Jan 2016, at 12:55, Martin Bjorklund <[email-masked]> wrote:
> 

If an argument starts as unquoted, then double quotes appearing inside it (or at the end) are accepted as literals. Backslash can appear anywhere in an unquoted argument, but it is less of a problem. So the above statement rewritten with a double-quoted argument is this:

description "\\\"hi\"";

I think that single and double quotes (and perhaps also backslashes) shouldn't be allowed in an unquoted argument.

Lada

---

From: Martin Bjorklund <[email-masked]>
Date: Fri, 29 Jan 2016 15:48:36 +0100 (CET)

Ladislav Lhotka <[email-masked]> wrote:
> If an argument starts as unquoted, then double quotes appearing inside
> it (or at the end) are accepted as literals. Backslash can appear
> anywhere in an unquoted argument, but it is less of a problem. So the
> above statement rewritten with a double-quoted argument is this:
> 
> description "\\\"hi\"";
> 
> I think that single and double quotes (and perhaps also backslashes)
> shouldn't be allowed in an unquoted argument.

Maybe, but this is a pretty big change, and the current rules "work",
and we're just about to publish a version can be sent to the IESG, so
I'd say that it is too late for this change.

/martin

---

From: Ladislav Lhotka <[email-masked]>
Date: Fri, 29 Jan 2016 15:58:26 +0100

> On 29 Jan 2016, at 15:48, Martin Bjorklund <[email-masked]> wrote:
> 

I know, but it opens space for nasty tricks like this:

$ cat quoting.yang 
module quoting {
  namespace "http://example.com/quoting";
  prefix qq;
  leaf foo {
    type string;
    default ​"hi";
  }
}
$ pyang -f yang quoting.yang
module quoting {
  namespace "http://example.com/quoting";
  prefix qq;

  leaf foo {
    type string;
    default "​\"hi\"";
  }
}

Weird, isn't it? It is because "ZERO WIDTH SPACE" (U+200B) immediately precedes the first double quote in the argument of "default". Consequently, the argument is parsed as unquoted, and both double quotes become part of it.

Lada