Skip to content

🐛 [Bug]: Potential issues with parameter parsing in findNextParamPosition and handling of routes with multiple :  #3289

Closed
@789748456v

Description

@789748456v

Bug Description

Hi Fiber team,
I’ve noticed two potential issues in the route-parsing logic:
The branch is main. fiber v3.

  1. Ineffective loop in path.go, func findNextParamPosition:
for found := findNextNonEscapedCharsetPosition(pattern[nextParamPosition+1:], parameterStartChars); found == 0; {
    nextParamPosition++
    if len(pattern) > nextParamPosition {
        break
    }
}

The condition if len(pattern) > nextParamPosition { break } appears to render the loop meaningless. Because nextParamPosition is guaranteed to be < len(pattern), the loop will always break after one iteration, which doesn’t seem to match the intended logic of skipping multiple consecutive : or similar parameter characters.

  1. Route like "/a:::" treated as having a parameter:
    If I register GET("/a:::"), tools like Express Route Tester treat it as a purely static route. However, Fiber currently interprets the final : as a parameter indicator. This creates an inconsistency with other routing systems where multiple : characters at the end might be interpreted as part of a static path or simply invalid syntax.

Could you clarify if this is the intended behavior? If not, might it be possible to update the logic in findNextParamPosition (and related parsing code) so that multiple consecutive : are handled more consistently, and routes like "/a:::" are treated as static?

Thank you for your time and for all your work on Fiber!

How to Reproduce

skip

Expected Behavior

skip

Fiber Version

v3 main

Code Snippet (optional)

Checklist:

  • I agree to follow Fiber's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions