Skip to content

Conversation

@mp0rta
Copy link

@mp0rta mp0rta commented Jan 7, 2026

fix #191

This PR fixes an incorrect conflation of VisibleString and PrintableString during
character-set validation.

VisibleString was previously validated against the PrintableString character
repertoire, which contradicts the VisibleString definition in X.680 and causes
valid VisibleString characters to be rejected when evaluating permitted-alphabet
constraints.

Changes

  • Separate VisibleString character-set handling from PrintableString
  • Model VisibleString using the ISO/IEC 646 visible character range (0x20..=0x7E)
  • Preserve existing PrintableString behavior

Result

  • Valid VisibleString characters such as '_' and '~' are no longer rejected
  • Permitted-alphabet constraints behave as specified in X.680
  • PrintableString semantics remain unchanged

@mp0rta
Copy link
Author

mp0rta commented Jan 7, 2026

I post the test result.
and I've checked the cargo test pass.

test asn file

TestVisibleStringConstraint DEFINITIONS ::= BEGIN

T ::= VisibleString
        (FROM ("a".."z" | "A".."Z" | "0".."9" | ":./-_@"))
        (SIZE (1..255))

END

before revision

Warnings:
Unidentified generating bindings for : Character _ is not in char set: {0: 'A', 1: 'B', 2: 'C', 3: 'D', 4: 'E', 5: 'F', 6: 'G', 7: 'H', 8: 'I', 9: 'J', 10: 'K', 11: 'L', 12: 'M', 13: 'N', 14: 'O', 15: 'P', 16: 'Q', 17: 'R', 18: 'S', 19: 'T', 20: 'U', 21: 'V', 22: 'W', 23: 'X', 24: 'Y', 25: 'Z', 26: 'a', 27: 'b', 28: 'c', 29: 'd', 30: 'e', 31: 'f', 32: 'g', 33: 'h', 34: 'i', 35: 'j', 36: 'k', 37: 'l', 38: 'm', 39: 'n', 40: 'o', 41: 'p', 42: 'q', 43: 'r', 44: 's', 45: 't', 46: 'u', 47: 'v', 48: 'w', 49: 'x', 50: 'y', 51: 'z', 52: '0', 53: '1', 54: '2', 55: '3', 56: '4', 57: '5', 58: '6', 59: '7', 60: '8', 61: '9', 62: ' ', 63: '\'', 64: '(', 65: ')', 66: '+', 67: ',', 68: '-', 69: '.', 70: '/', 71: ':', 72: '=', 73: '?'}


Generated:
#[allow(
    non_camel_case_types,
    non_snake_case,
    non_upper_case_globals,
    unused,
    clippy::too_many_arguments
)]
pub mod test_visible_string_constraint {
    extern crate alloc;
    use core::borrow::Borrow;
    use rasn::prelude::*;
    use std::sync::LazyLock;
}

after revision

Generated:
#[allow(
    non_camel_case_types,
    non_snake_case,
    non_upper_case_globals,
    unused,
    clippy::too_many_arguments
)]
pub mod test_visible_string_constraint {
    extern crate alloc;
    use core::borrow::Borrow;
    use rasn::prelude::*;
    use std::sync::LazyLock;
    #[doc = " Minimal reproduction for permitted alphabet + size constraints on VisibleString"]
    #[derive(AsnType, Debug, Clone, Decode, Encode, PartialEq, Eq, Hash)]
    #[rasn(
        delegate,
        size("1..=255"),
        from(
            "\u{2d}",
            "\u{2e}",
            "\u{2f}",
            "\u{30}..=\u{39}",
            "\u{3a}",
            "\u{40}",
            "\u{41}..=\u{5a}",
            "\u{5f}",
            "\u{61}..=\u{7a}"
        )
    )]
    pub struct T(pub VisibleString);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect character set used for VisibleString (X.680 / ISO 646)

1 participant