Open v-po opened 2 months ago
To be frank, I'm no expert for RFC 6690. Over the years not too many seems to use that extensively. What's is your use-case, which is affected by the misbehavior?
@boaks Not entirely sure what you mean by use-case, but we are using parts of californium in an Android app and in a Resource Directory backend. And we have IoT devices that send data in the formats outlined above (when querying "/.well-known/core") which caused problems when we tried using the LinkFormat
parser. For us it's not a very big issue, as we don't use the californium CoapClient, so we can get by with our own Core Links parser. I guess it will be a problem for someone who uses CoapClient.discover()
and receives data like the one specified above.
Not entirely sure what you mean by use-case
"Resource Directory" is the kind of answer I was looking for.
For us it's not a very big issue
OK.
If you're interested to get answers for your points and interpretations from the IETF core-group, the easiest way is to copy the issue into corrclar issue.
We can alternatively convert your solution into a PR and see, if someone has issues with it.
(I'm personally on the way to ramp down my engagement to a hobby/free time level. Therefore the handling of the clarification on my side will take some time.)
On my side, I never used Californium classes to parse Link Format. But I faced this RFC 6690 with LWM2M and I also feel this is a not so easy to implement RFC. (especially because of extensibility ...)
In Leshan we try to implement a CoRE Link Parser, all classes are in leshan-lwm2m-core@org/eclipse/leshan/core/link/
I have encountered some issues with the
LinkFormat.parse()
method when parsing certain payloads. I realize the current implementation is very simple. And maybe the following points are not even considered bugs, in which case feel free to close this issue. I'm also hoping that I have not completely misunderstood the main RFC 6690, or any of the linked ones :sweat_smile:.The current parser seems to have the following problems:
1. Incorrect handling of certain characters in Attribute Values
Parsing stops when encountering certain characters that are valid in
relation-types
. Specifically, it fails when handling characters such as dots (.), hyphens (-), and colons (:).Expected output:
Actual output:
It appears that the issue is caused by the regex pattern used for
WORD
.However, I'm not sure if simply extending this regex to include those characters will fix it. It might even make it worse :)
2. Incorrect handling of quoted strings for non-
relation-type
attributesThe current parser splits all quoted strings into separate values when encountering spaces, regardless of the attribute type. If I understood correctly, only specific attributes (such as
rel
,rev
,rt
, andif
) should have their quoted strings split into space-separated values. All other attributes should treat quoted strings as single entities, even if they contain spaces.Expected output:
Actual output:
3. (Maybe issue) Handling of attributes without values (e.g., observability flags)
I decided to represent them as the empty list, instead of the list containing the empty string as californium treats them, since an attribute like
a=""
seemed distinct than justa
I'm sure there are other issues with the parser (for example I didn't see any handling of
ext-value
) as the whole specification is (imo) a giant mess of interlinking RFCs. These are just the ones that I came across.My own solution
I don't know if this is of value to anyone else, but this is the code that I'm currently using to using to get around these issues. It's nowhere near "RFC-compliant" and also not very efficient with the String allocations.
Core Links parser in Kotlin
```kotlin typealias AttributeName = String typealias AttributeValues = List