-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix accounts search by full/partial display name and others
- Restrict followers counts to local users to minimize local advantage - Fix emoji shortcodes causing error in search - Fix search syntax parse errors not being caught
- Loading branch information
Showing
5 changed files
with
25 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class SearchQueryParser < Parslet::Parser | ||
rule(:term) { match('[^\s":]').repeat(1).as(:term) } | ||
rule(:quote) { str('"') } | ||
rule(:colon) { str(':') } | ||
rule(:space) { match('\s').repeat(1) } | ||
rule(:operator) { (str('+') | str('-')).as(:operator) } | ||
rule(:prefix) { (term >> colon).as(:prefix) } | ||
rule(:phrase) { (quote >> (term >> space.maybe).repeat >> quote).as(:phrase) } | ||
rule(:clause) { (prefix.maybe >> operator.maybe >> (phrase | term)).as(:clause) } | ||
rule(:query) { (clause >> space.maybe).repeat.as(:query) } | ||
rule(:term) { match('[^\s":]').repeat(1).as(:term) } | ||
rule(:quote) { str('"') } | ||
rule(:colon) { str(':') } | ||
rule(:space) { match('\s').repeat(1) } | ||
rule(:operator) { (str('+') | str('-')).as(:operator) } | ||
rule(:prefix) { (term >> colon).as(:prefix) } | ||
rule(:shortcode) { (colon >> term >> colon.maybe).as(:shortcode) } | ||
rule(:phrase) { (quote >> (term >> space.maybe).repeat >> quote).as(:phrase) } | ||
rule(:clause) { (prefix.maybe >> operator.maybe >> (phrase | term | shortcode)).as(:clause) } | ||
rule(:query) { (clause >> space.maybe).repeat.as(:query) } | ||
root(:query) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters