This guide highlights the key changes introduced in recent releases and how to adapt code written for earlier versions of cotlib.
- Unexported security constants: Limits such as
MaxDetailSize,MinStaleOffsetandMaxStaleOffsetwere unexported in v0.2.3. Use the setter functions (SetMaxXMLSize,SetMaxElementDepth,SetMaxElementCount,SetMaxTokenLenandSetMaxValueLen) to customise limits. - Detail structure updates: Detail extensions now preserve XML attributes and unknown elements are captured in
Detail.Unknown. Code that accessed plain strings should parse the new structures or handle the raw XML stored in these fields. - Time validation:
stalemust be at least five seconds aftertimeand no more than seven days later. Events outside this range fail validation. - Secure XML decoder: DOCTYPE declarations are rejected and parser limits are enforced on every decode call. Ensure input XML conforms to these restrictions.
Default parsing limits are configured in init():
- Maximum XML size: 2 MB
- Maximum element depth: 32
- Maximum element count: 10,000
- Maximum token length: 1,024 bytes
- Maximum attribute or text length: 512 KiB
Adjust these values with the setter functions if needed.
- Remove references to the old exported constants and rely on the setter functions to change limits.
- When unmarshalling events, inspect
Detail.Unknownfor unrecognised extensions. Known extensions (such asChatorRemarks) expose structured fields with preserved attributes. - Validate events with
Event.Validate()to enforce the new time checks. - After processing, release events using
ReleaseEvent()to return them to the pool.
Following these steps will ensure your application remains compatible with the latest library version.