post queries: track whether metatag values are quoted.

This is necessary for the `commentary:` metatag, which has different
behavior depending on whether the metatag value is quoted. For example,
`commentary:translated` finds translated commentaries, while
`commentary:"translated"` finds commentaries containing the literal word
"translated".
This commit is contained in:
evazion
2022-04-06 17:15:02 -05:00
parent 2adc530ba0
commit a4d43ae72a
3 changed files with 17 additions and 12 deletions

View File

@@ -164,8 +164,8 @@ class PostQuery
if accept(METATAG_NAME_REGEX)
name = @scanner.matched.delete_suffix(":").downcase
name = name.singularize + "_count" if name.in?(PostQueryBuilder::COUNT_METATAG_SYNONYMS)
value = quoted_string
node(:metatag, name, value)
quoted, value = quoted_string
node(:metatag, name, value, quoted)
end
end
@@ -173,13 +173,13 @@ class PostQuery
if accept('"')
a = accept(/([^"\\]|\\")*/).gsub(/\\"/, '"') # handle backslash escaped quotes
expect('"')
a
[true, a]
elsif accept("'")
a = accept(/([^'\\]|\\')*/).gsub(/\\'/, "'") # handle backslash escaped quotes
expect("'")
a
[true, a]
else
string(/[^ ]+/)
[false, string(/[^ ]+/)]
end
end