Skip to content

Commit bd3f80e

Browse files
authored
fix: Replace single quotes ' with typographical quotes to avoid syntax errors (#994)
Fixes github/continuous-ai-for-accessibility#61 (Hubber access only) Inspired by @abdulahmad307’s single-quote handling in [axeRuleManager.ts#L57-L60](https://github.com/github/accessibility-scorecard/blob/e554f2588c30a26b4e9c35ee48c527340bbb72ef/.github/actions/get-page-axe-violations-service-maps/src/axeRuleManager.ts#L57-L60) (Hubber access only) When findings include single quotes, attempts to cache them can fail with errors like: ``` syntax error near unexpected token `(' ``` One solution would be to escape single quotes; however, all tools (shell and node) that interact with this string would need to handle the escaped characters the same way. Instead, this PR’s approach replaces single quote characters with typographical quotes, which do not need to be escaped.
2 parents 60ad8c7 + fb7740a commit bd3f80e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

.github/actions/find/src/findForUrl.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ export async function findForUrl(url: string): Promise<Finding[]> {
1515
scannerType: 'axe',
1616
url,
1717
html: violation.nodes[0].html,
18-
problemShort: violation.help.toLowerCase(),
19-
problemUrl: violation.helpUrl,
18+
problemShort: violation.help.toLowerCase().replace(/[']/g, '’'),
19+
problemUrl: violation.helpUrl.replace(/[']/g, '’'),
2020
ruleId: violation.id,
21-
solutionShort: violation.description.toLowerCase(),
22-
solutionLong: violation.nodes[0].failureSummary
21+
solutionShort: violation.description.toLowerCase().replace(/[']/g, '’'),
22+
solutionLong: violation.nodes[0].failureSummary?.replace(/[']/g, '’')
2323
}));
2424
} catch (e) {
2525
// do something with the error

0 commit comments

Comments
 (0)