Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion InfoLogger/public/logFilter/LogFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default class LogFilter extends Observable {
delete criterias[field][operator];
} else if (operator === 'match' || operator === 'exclude') {
// encode potential breaking characters and escape double quotes as are used by browser by default
criterias[field][operator] = encodeURI(criterias[field][operator].replace(/["]+/g, '\\"'));
criterias[field][operator] = encodeURIComponent(criterias[field][operator].replace(/["]+/g, '\\"'));
}

// remove empty fields
Expand Down
24 changes: 24 additions & 0 deletions InfoLogger/test/public/log-filter-actions-mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,30 @@ describe('Filter actions test-suite', async () => {
assert.deepStrictEqual($in, ['I', 'W', 'E', 'F']);
});

it('should encode special characters correctly into the URL', async () => {
const pidMatch = await page.evaluate(() => {
window.model.log.filter.setCriteria('pid', 'match', 'a+b c %d #anchor & = héllo wörld 日本語');
return window.model.log.filter.criterias.pid.$match;
});

assert.strictEqual(pidMatch, 'a+b c %d #anchor & = héllo wörld 日本語');

const searchParams = await page.evaluate(() => {
window.model.updateRouteOnModelChange();
return window.location.search;
});

assert.ok(searchParams.includes('a%2Bb%20c%20%25d%20%23anchor%20%26%20%3D%20h%C3%A9llo%20w%C3%B6rld%20%E6%97%A5%E6%9C%AC%E8%AA%9E'));
});

it('should decode special characters correctly from the URL', async () => {
await page.goto(`${baseUrl}?q={%22pid%22:{%22match%22:%22a%2Bb%20c%20%25d%20%23anchor%20%26%20%3D%20h%C3%A9llo%20w%C3%B6rld%20%E6%97%A5%E6%9C%AC%E8%AA%9E%22}}`, { waitUntil: 'networkidle0' });

const pidMatch = await page.evaluate(() => window.model.log.filter.criterias.pid.$match);

assert.strictEqual(pidMatch, 'a+b c %d #anchor & = héllo wörld 日本語');
});

it('should reset filters and set them again', async () => {
const criterias = await page.evaluate(() => {
window.model.log.filter.resetCriteria();
Expand Down