Magnus,

You could define your own type and write what you say below in the description. 
It may not be important to construct a YANG pattern that captures X.680 
exactly. Your server (and client) implementations can still reject transactions 
containing illegal characters based on the description.

Best Regards,
/jan

> The ask from Balázs originated from me who noticed that we in 3GPP have 
> defined some parameters in interfaces to conform to ASN.1 visible and 
> printable strings. Then in specification of IOCs specified that the IOC 
> attributes should conform to the visible and printable string formats defined 
> in ITU-T X.680, but when defined in Yang a normal string type was 
> accidentally used allowing any char to be injected.
> My simple ask was then whether there already exist standardized yang types 
> for the string types defined in ITU-T X.680, or if we should propose such 
> types to be defined (and then of course used in the 3GPP provided Yang files).
> 
> It is of course good the Yang language is supportive to define custom types. 
> Then it is "just do it", which is easier said than done, impacting a 
> significant set or already released 3GPP released yang files.
> BR Magnus
> 
> -----Original Message-----
> From: Ladislav Lhotka <[email protected]> 
> Sent: den 19 oktober 2021 09:58
> To: Jan Lindblad <[email protected]>; Balázs Lengyel 
> <[email protected]>
> Cc: [email protected]; Magnus Standar <[email protected]>
> Subject: Re: [netmod] Printable or visible string in YANG
> 
> On 19. 10. 21 9:06, Jan Lindblad wrote:
>> Hi Balazs,
>> 
>> And don't forget that in YANG 1.1 you can exclude characters.
>> 
>> type string {
>>   pattern ".*\n.*" { modifier invert-match; } // Disallow newline characters
>>   pattern ".*\r.*" { modifier invert-match; } // Disallow carriage 
>> return characters }
> 
> It is also worth noting that in fact (sec. 9.4 in RFC 7950) "The string 
> built-in type represents human-readable strings in YANG." This may possibly 
> be what Balazs wants, although I doubt that there is an implementation that 
> can really *print* all such strings.
> 
> Lada
> 
>> 
>> /jan
>> 
>> 
>> 
>>> On 18 Oct 2021, at 13:24, Ladislav Lhotka <[email protected]> wrote:
>>> 
>>> Hi Balazs,
>>> 
>>> Unicode (if you mean it) is so convoluted that the notion of 
>>> printable/visible characters doesn't make much sense. It is IMO much safer 
>>> to specify character classes that you want to permit.
>>> 
>>> Lada
>>> 
>>> On 18. 10. 21 12:11, Balázs Lengyel wrote:
>>>> Hello,
>>>> Is there a way in YANG to restrict a string to printable or visible 
>>>> characters? (Something like SNMP DisplayString) Regards Balazs
>>>> -- 
>>>> Balazs Lengyel                    Senior Specialist                       
>>>> Ericsson Hungary Ltd.
>>>> Mobile: +36-70-330-7909              email: [email protected]
>>>> _______________________________________________
>>>> netmod mailing list
>>>> [email protected]
>>>> https://www.ietf.org/mailman/listinfo/netmod
>>> 
>>> --
>>> Ladislav Lhotka
>>> Head, CZ.NIC Labs
>>> PGP Key ID: 0xB8F92B08A9F76C67
>>> 
>>> _______________________________________________
>>> netmod mailing list
>>> [email protected]
>>> https://www.ietf.org/mailman/listinfo/netmod
>> 
> 
> --
> Ladislav Lhotka
> Head, CZ.NIC Labs
> PGP Key ID: 0xB8F92B08A9F76C67

_______________________________________________
netmod mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/netmod

Reply via email to