fix: prevent non-sponsors from bypassing GIF restriction (v2.0.1)#10
Merged
lucas-adm merged 2 commits intoNoteHubBR:mainfrom Dec 17, 2025
Merged
Conversation
- Add validateGif() method to enforce GIF restrictions server-side - Prevent users from bypassing frontend validation by copying sponsor URLs - GIFs remain blocked for banners regardless of sponsor status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sumário
Este PR corrige usuários não-patrocinadores conseguindo burlar a restrição de GIFs ao copiar URLs de imagens de patrocinadores e fazer requisições diretas via API, contornando a validação do frontend.
Alterações
UserServiceImpl.java-> Adicionado métodovalidateGif();CustomExceptions.java->GifNotAllowedException;ControllerAdvice.java-> Handler para nova exceção;2.0.1.Necessidade
A validação de GIFs estava implementada apenas no frontend, permitindo que usuários contornassem a restrição de patrocinadores ao fazerem requisições diretas via API com URLs copiadas. Esta correção garante que as regras de negócio sejam validadas no servidor, independente da origem da requisição.
Teste manual
/api/v1/users/profile-> (Payload, Response)/(200 OK, 403 Forbidden){ "username": "test", "displayName": "Test", "avatar": "https://example.com/image.gif", "banner": "https://example.com/image.gif", "message": "Lorem Ipsum", "profilePrivate": false }[ { "field": "avatar", "message": "GIFs apenas para patrocinadores." }, { "field": "banner", "message": "GIFs são proibidos como banner." } ]Checklist
Breaking Changes