Skip to content

Commit

Permalink
Pull request: 3201 use backslash to escape quotes in the client name
Browse files Browse the repository at this point in the history
Closes AdguardTeam#3201

Squashed commit of the following:

commit 43d2b96
Merge: 36eeb1b 784bc31
Author: Ildar Kamalov <ik@adguard.com>
Date:   Mon Aug 16 17:29:06 2021 +0300

    Merge branch 'master' into 3201-escape-quotes

commit 36eeb1b
Author: Ildar Kamalov <ik@adguard.com>
Date:   Mon Aug 16 15:56:15 2021 +0300

    client: multiple escape

commit e7c19dd
Author: Ildar Kamalov <ik@adguard.com>
Date:   Mon Aug 16 12:04:43 2021 +0300

    client: use backslash to escape quotes in the client name
  • Loading branch information
IldarKamalov committed Aug 16, 2021
1 parent 784bc31 commit 42b2c3a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,11 @@ export const toggleBlocking = (
};

export const toggleBlockingForClient = (type, domain, client) => {
const baseRule = `||${domain}^$client='${client.replace(/'/g, '/\'')}'`;
const escapedClientName = client.replace(/'/g, '\\\'')
.replace(/"/g, '\\"')
.replace(/,/g, '\\,')
.replace(/\|/g, '\\|');
const baseRule = `||${domain}^$client='${escapedClientName}'`;
const baseUnblocking = `@@${baseRule}`;

return toggleBlocking(type, domain, baseRule, baseUnblocking);
Expand Down

0 comments on commit 42b2c3a

Please sign in to comment.