openrdap / rdap

RDAP command line client
https://www.openrdap.org
MIT License
225 stars 34 forks source link

LACNIC VCard issue #25

Closed g00g1 closed 8 months ago

g00g1 commented 8 months ago

Hello.

I am trying to access VCard property of LACNIC resources (for example, IPv4 address 148.223.0.0), however it seems like openrdap/rdap package is unable to parse their response due to jCard error: jCard property too short (>=4 array elements required) while decoding the VCard field.

Is this the intended behaviour or known issue?

skip2 commented 8 months ago

Hello, It looks like you've identified the LACNIC RDAP service responding with invalid jCards (jCard = JSON vCard):

The jCard format used in RDAP specifies a "language-tag" as the following: https://www.rfc-editor.org/rfc/rfc7095#section-3.5.12

   ["lang", {}, "language-tag", "de"]

However for your example IP 148.223.0.0, the LACNIC RDAP service returns the following instead:

[
  "lang",
  {
    "type": "language-tag"
  },
  "en"
]

(i.e. the array contains three elements when the minimum is four, and it doesn't match RFC7095 3.5.12).

I will report this to LACNIC :).

skip2 commented 8 months ago

The jCard parser currently refuses to parse a jCard if there are any errors.

Would you be interested in a function which parses a jCard as best as possible, and ignores any invalid properties?

g00g1 commented 8 months ago

Would you be interested in a function which parses a jCard as best as possible, and ignores any invalid properties?

Yes, that would be very helpful.

skip2 commented 8 months ago

It looks like LACNIC has fixed their responses already (with an impressive response time on a Sunday!), as the 148.223.0.0 example now returns the correct format:

          [
            "lang",
            {},
            "language-tag",
            "en"
          ]

Thus your initial problem should be resolved.

I'll continue to work on commit https://github.com/openrdap/rdap/commit/79e3d521a14aa904d862e11c3da19e2d342b966a, it has usage like vcard, err := NewVCardWithOptions(json, VCardOptions{IgnoreInvalidProperties: true}) to ignore invalid properties.

skip2 commented 8 months ago

https://github.com/openrdap/rdap/blob/master/vcard.go#L153

skip2 commented 8 months ago

Alright, I think the problem is solved in two ways now :)