tomMoulard / htransformation

A Traefik plugin to change on the fly header's value of a request
MIT License
77 stars 13 forks source link

Rewrite handler crash when there's no match #33

Closed leshik closed 2 years ago

leshik commented 2 years ago

When there's no match, the rewrite handler crashes here with:

reflect.Value.Slice: slice index out of bounds  middlewareName=traefik-internal-recovery middlewareType=Recovery
tomMoulard commented 2 years ago

Hello @leshik,

Thanks for your interest in this Traefik plugin,

Can you elaborate on the bug you seem to have ?

For this matcher, I've added test on this there : 167b62e357783aef693ac269f362a207f81003a0 https://github.com/tomMoulard/htransformation/blob/0e8eec39a1beff3140ccc6f26d1bb1c503905bac/pkg/handler/rewrite/rewrite_test.go#L56-L68

leshik commented 2 years ago

Hi @tomMoulard,

I suppose there might be a missing continue inside the if block, and range then panics on an empty captures slice.

tomMoulard commented 2 years ago

This should be fixed in 5e973ec83c29f5654d00a768da4621120e3873f1.

Thanks :smiley:

EDIT: If you can, can you please try my fix. If it works, I'll do a release.

leshik commented 2 years ago

@tomMoulard sorry, missed the EDIT. Yes, the fix works.