'use strict' // Characters. var nil = '\0' var ampersand = '&' var space = ' ' var tab = '\t' var graveAccent = '`' var quotationMark = '"' var apostrophe = "'" var equalsTo = '=' var lessThan = '<' var greaterThan = '>' var slash = '/' var lineFeed = '\n' var carriageReturn = '\r' var formFeed = '\f' var whitespace = [space, tab, lineFeed, carriageReturn, formFeed] // See: . var name = whitespace.concat(ampersand, slash, greaterThan, equalsTo) // See: . var unquoted = whitespace.concat(ampersand, greaterThan) var unquotedSafe = unquoted.concat( nil, quotationMark, apostrophe, lessThan, equalsTo, graveAccent ) // See: . var singleQuoted = [ampersand, apostrophe] // See: . var doubleQuoted = [ampersand, quotationMark] // Maps of subsets. // Each value is a matrix of tuples. // The first value causes parse errors, the second is valid. // Of both values, the first value is unsafe, and the second is safe. module.exports = { name: [ [name, name.concat(quotationMark, apostrophe, graveAccent)], [ name.concat(nil, quotationMark, apostrophe, lessThan), name.concat(nil, quotationMark, apostrophe, lessThan, graveAccent) ] ], unquoted: [ [unquoted, unquotedSafe], [unquotedSafe, unquotedSafe] ], single: [ [singleQuoted, singleQuoted.concat(quotationMark, graveAccent)], [ singleQuoted.concat(nil), singleQuoted.concat(nil, quotationMark, graveAccent) ] ], double: [ [doubleQuoted, doubleQuoted.concat(apostrophe, graveAccent)], [ doubleQuoted.concat(nil), doubleQuoted.concat(nil, apostrophe, graveAccent) ] ] }