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

Escape sourceLabel ids when invalid characters are present #3351

Merged
merged 4 commits into from Jan 10, 2018

Conversation

llienher
Copy link
Member

@llienher llienher commented Jan 9, 2018

Fixes #3273.

With this fix, we escape the IDs (generated from the value in ctrl.mergeTabs for merged tabs or OL datasource). If an invalid value would result in an invalid ID selector (css), then the value is stripped from unauthorized characters. Other change is the use of the datasource IDs for the HTML ids instead of the label value that contained spaces, etc.

Ideally ids defined in the ctrl.mergeTabs should have no spaces, or any specific characters such as parentheses, brackets, etc. This fix allow all project to work without changing ids manually, but if possible having a correct value is just best practice...

In that context I changed the value in our desktop example, while the fix was tested on the previous value, 'OSM time merged'.

Copy link
Member

@ger-benjamin ger-benjamin left a comment

Choose a reason for hiding this comment

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

I think that's better to have a function that return the escaped id and called here: https://github.com/camptocamp/ngeo/blob/2.2/contribs/gmf/src/directives/partials/displayquerygrid.html#L41

@llienher llienher force-pushed the displayquerygrid-tab-headers branch from d32761c to ba47927 Compare January 9, 2018 12:46
@llienher
Copy link
Member Author

llienher commented Jan 9, 2018

@ger-benjamin I refactored the code. Now it is escaped at data generation (before the function that going to fill the grid). I did the change to use Ids again in the HTML instead of the labels. Labels are still used for the tab labels, so nothing change for the user.

Copy link
Member

@ger-benjamin ger-benjamin left a comment

Choose a reason for hiding this comment

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

Thanks.
Looks good but please, test carefully before to merge.

/**
* Returns an escaped value.
* @param {string|number} value A value to escape.
* @returns {string|number} value An escaped valjue.
Copy link
Member

Choose a reason for hiding this comment

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

typo

@llienher llienher force-pushed the displayquerygrid-tab-headers branch from 6b704fc to e8e42dd Compare January 9, 2018 14:13
@llienher llienher force-pushed the displayquerygrid-tab-headers branch from e8e42dd to bc2ae5a Compare January 9, 2018 14:13
@llienher
Copy link
Member Author

@ger-benjamin I added two merged tabs in desktop_alt to make sure we have correct testing setup.

@llienher llienher merged commit 19c1156 into 2.2 Jan 10, 2018
@llienher llienher deleted the displayquerygrid-tab-headers branch January 10, 2018 10:39
@sbrunner sbrunner added this to the 2.2 milestone Jan 16, 2018
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

3 participants