Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created new Filter to intercept and normalizate URIs #17809

Merged
merged 2 commits into from
Jan 10, 2020

Conversation

jgambarios
Copy link
Contributor

@jgambarios jgambarios commented Jan 10, 2020

Fix for ticket #17796
A filter was created to wrap all the incoming requests to override the HttpServletRequest.getRequestURI() method in order to normalize all the requested URIs.

Copy link
Contributor

@wezell wezell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work

}

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* invalids URIs
*/
@Test
public void test_uri_normalization_invalid_URI() throws IOException, ServletException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* valid URIs
*/
@Test
public void test_uri_normalization_valid_URI() throws IOException, ServletException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private void compare(final String originalURI, final String expectedNormalizedURI)
throws IOException, ServletException {

HttpServletRequest request = mock(HttpServletRequest.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

@Override
public void destroy() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public class NormalizationFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public class NormalizationFilter implements Filter {

@Override
public void init(FilterConfig filterConfig) throws ServletException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain filterChain) throws IOException, ServletException {

HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgambarios jgambarios merged commit c498997 into master Jan 10, 2020
@delete-merged-branch delete-merged-branch bot deleted the NormalizationFilter branch January 10, 2020 17:49
@jgambarios jgambarios mentioned this pull request Jan 10, 2020
jgambarios added a commit that referenced this pull request Jan 13, 2020
* Created new Filter to intercept and normalizate URIs

* Applied feedback #17796

(cherry picked from commit c498997)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants