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

Filter causes duplication of query parameters #9100

Closed
alansemenov opened this issue Sep 27, 2021 · 2 comments
Closed

Filter causes duplication of query parameters #9100

alansemenov opened this issue Sep 27, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@alansemenov
Copy link
Member

alansemenov commented Sep 27, 2021

site.xml:

  <mappings>
    <mapping filter="/site/mappings/filter.js">
      <pattern>/filter</pattern>
    </mapping>
  </mappings>
</site>

/site/mappings/filter.js:

exports.filter = function (req, next) {
    log.info(JSON.stringify(req.params, null, 4));
    return next(req);
};

A part added to the default site's template:

exports.get = function (req, next) {
    log.info(JSON.stringify(req.params, null, 4));
    return {
        contentType: 'text/html',
        body: body
    };
};

This setup will output the following in the XP log for url http://localhost:8080/admin/site/preview/default/draft/features/filter?q=1:

16:18:35.280 INFO  com.enonic.app.features - (/site/mappings/filter.js) {
    "q": "1"
}
16:18:35.289 INFO  com.enonic.app.features - (/site/parts/my-part/my-part.js) {
    "q": [
        "1",
        "1"
    ]
}

After going through the filter, q parameter becomes an array with duplicated value.

@alansemenov alansemenov added this to the 7.7.4 milestone Sep 27, 2021
@rymsha rymsha modified the milestones: 7.7.4, 7.8.0 Sep 30, 2021
@rymsha
Copy link
Contributor

rymsha commented Sep 30, 2021

It appeared after #8210 (although, it is not a regression)

Interestingly enough we are not the first who face such issue jetty/jetty.project#2074

@rymsha
Copy link
Contributor

rymsha commented Sep 30, 2021

prams from filter result are appended to params with the same name - that is causing bug in cases where filter uses next as a return value.

To do a fix we decided to changes the behavior:
prams with the same name in filter result replace params in the original request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants