asn1tools icon indicating copy to clipboard operation
asn1tools copied to clipboard

Error when '_' is in the asn file

Open chuanxiao258 opened this issue 4 years ago • 5 comments

When I was using your asn1tools on python3.7.4, I found if there is a ‘_’ in the asn file, the IDLE will raise an error. I attach a script below, hoping for your help , thanks. new.zip

chuanxiao258 avatar Oct 16 '20 02:10 chuanxiao258

the python code is here:

import asn1tools

asn1tools.compile_files('new.asn','uper')

chuanxiao258 avatar Oct 16 '20 02:10 chuanxiao258

Thanks for the good description of the issue. I'm afraid that _ in enum and sequence member names are not allowed in ASN.1. Only - is allowed.

eerimoq avatar Oct 16 '20 05:10 eerimoq

Thanks for your kind reply, but when I put this asn file to the https://asn1.io/asn1playground/, it can pass the compiling and encoding, which seems the '_' is allowed in ASN.1. Could you just make another try on the website? Below are the asn file and the value of it, thanks.

World-Schema DEFINITIONS AUTOMATIC TAGS ::= BEGIN Asn1test ::= SEQUENCE { test Test OPTIONAL }

Test ::= SEQUENCE{ test1 INTEGER(0..200), test2 Test2 } Test2 ::= ENUMERATED{ test_De0 (0), test_De1 (1), test_De2 (2), test_De3 (3), test_De4 (4), test_De5 (5), test_De6 (6), test_De7 (7) }
END

value Asn1test ::= { test { test1 100 test2 test_De0 } }

chuanxiao258 avatar Oct 16 '20 05:10 chuanxiao258

Hi!

Please read the ASN.1 specification and tell me where is says that _ is allowed. Just because one implementation supports it doesn't mean it's according to specification. It very well may be allowed, but I've not read it anywhere.

eerimoq avatar Oct 16 '20 06:10 eerimoq

Related/Duplicate of: #68 See also this pull request: #173

laf0rge avatar Dec 09 '23 15:12 laf0rge