post queries: support single-quoted strings in metatags.

This commit is contained in:
evazion
2022-04-04 18:53:58 -05:00
parent 88be28ae36
commit 783419bcd7
3 changed files with 13 additions and 1 deletions

View File

@@ -358,7 +358,7 @@ class PostQuery
def quoted_value
return nil unless metatag?
if value.include?(" ") || value.starts_with?('"') || value.empty?
if value.include?(" ") || value.starts_with?('"') || value.starts_with?("'") || value.empty?
%Q{"#{value.gsub(/"/, '\\"')}"}
else
value

View File

@@ -24,6 +24,7 @@ require "strscan"
# metatag = metatag_name ":" quoted_string
# metatag_name = "user" | "fav" | "pool" | "order" | ...
# quoted_string = '"' /[^"]+/ '"'
# | "'" /[^']+/ "'"
# tag = /[^ *]+/
# wildcard = /[^ ]+/
#
@@ -172,6 +173,10 @@ class PostQuery
a = accept(/([^"\\]|\\")*/).gsub(/\\"/, '"') # handle backslash escaped quotes
expect('"')
a
elsif accept("'")
a = accept(/([^'\\]|\\')*/).gsub(/\\'/, "'") # handle backslash escaped quotes
expect("'")
a
else
string(/[^ ]+/)
end