Skip to content

Commit 01dc673

Browse files
committed
Return 404 error for invalid URLs with double slashes.
Prior this change, it led to 500 error and long error stack traces in a log file.
1 parent 718c612 commit 01dc673

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/main/java/ru/mystamps/web/support/spring/boot/ErrorPagesCustomizer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.springframework.boot.web.servlet.ErrorPageRegistrar;
2525
import org.springframework.boot.web.servlet.ErrorPageRegistry;
2626

27+
import org.springframework.security.web.firewall.RequestRejectedException;
28+
2729
import ru.mystamps.web.Url;
2830

2931
@Configuration
@@ -34,6 +36,7 @@ public void registerErrorPages(ErrorPageRegistry registry) {
3436
registry.addErrorPages(
3537
new ErrorPage(HttpStatus.FORBIDDEN, Url.FORBIDDEN_PAGE),
3638
new ErrorPage(HttpStatus.NOT_FOUND, Url.NOT_FOUND_PAGE),
39+
new ErrorPage(RequestRejectedException.class, Url.NOT_FOUND_PAGE),
3740
new ErrorPage(Exception.class, Url.INTERNAL_ERROR_PAGE)
3841
);
3942
}

0 commit comments

Comments
 (0)