* Attempt to eliminate polynomial regular expression used on uncontrolled data Closes https://github.com/github/docs-internal/security/code-scanning/112?query=ref%3Arefs%2Fheads%2Fmain Closes https://github.com/github/docs-internal/security/code-scanning/107?query=ref%3Arefs%2Fheads%2Fmain * Attempt to eliminate incomplete multi-character sanitization Closes https://github.com/github/docs-internal/security/code-scanning/113?query=ref%3Arefs%2Fheads%2Fmain * Keep closer to original pattern for now Co-authored-by: Peter Bengtsson <peterbe@github.com> Co-authored-by: Peter Bengtsson <peterbe@github.com>
12 lines
441 B
JavaScript
12 lines
441 B
JavaScript
import patterns from './patterns.js'
|
|
// This module searches a string for references to data objects
|
|
// It finds all references matching {{site.data.*}} and return an array of them
|
|
|
|
export default function getLiquidDataReferences(text) {
|
|
return (text.match(patterns.dataReference) || []).map((ref) => {
|
|
const cleaned = ref.replace(/\.+\//g, '').replace('{% data', '').replace('%}', '').trim()
|
|
|
|
return `site.data.${cleaned}`
|
|
})
|
|
}
|