Skip to content

substring() panics when length parameter exceeds the remaining string length #109

@inuwashi123

Description

@inuwashi123

I've encountered an issue with the substring() function in the antchfx/xpath package. According to the XPath specification, if the length parameter exceeds the actual remaining length of the string, the function should return the substring from the specified start position to the end of the string, rather than causing an error.

Additional Information:

  1. It seems that the current implementation does not perform adequate bounds checking when slicing the string, resulting in a panic when the length parameter is too large.

  2. A potential fix would be to check the bounds and adjust the length to return the substring from the start position to the end of the string if the requested length exceeds the available characters.

Could you please look into this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions