New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow quoted source: metatag, allow source: metatag when editing posts #2679
Conversation
I'm honestly not a fan of this. Quotes aren't used in this manner anywhere else so why would this specific use case with tagging the source enable it? To give an example of elsewhere where you might expect to be able to do this: tagging the pool with the title, favorites, favgroups. This also applies to search. Can you search for source using the quotes? You also get into issues like, should escaped quotes be parsed? To answer your specific questions, % is stripped out because it has a special meaning in SQL LIKE queries. Commas are stripped out because they are used as a delimiter in some places. Null/empty string sources are already accounted for so probably nothing needs to be done about that. cc @evazion |
Yeah, I can see that inconsistence is annoying, but sources are a bit of special case. Everything besides source internally replaces spaces with underscores, so it never was a problem in other cases. This actually was requested multiple times, see #2178, #1548. That said, why not extend the solution and allow quotes in the cases you mentioned, too?
Yes, the changes made to
I left that for the future, as spaces are used way more often than quotes, both for search and for specifying the source, and unlike space, |
Why not allow it? Not especially useful for current metatags, but imagine being able to search stuff like I do think it's pretty hacky though trying to do this with regexes. IMO in a perfect world tag searches would be parsed by a real parser instead of a bunch of regexes.
IMO text fields should be enforced as
That lets you escape |
Well, Ruby has a decent native regexp support, but I don't remember it having built-in lexers. Either way, it's easily done with two or three regexps, why bother with parser? Allowing other metatags to have quoted values will not require new regexp, only amending an existing one: |
Technically, escaped |
Programming languages do that for programmers' sake, to write escape sequences instead of charcodes. It might have been necessary if we had to escape anything besides |
Well, if you want to escape |
Nope, I'll be able to tell - if it's followed by We are not processing the string as character sequence anyway. Unescaping is done by calling replace on |
Re: escaping quotes and backslashes, @DennouNeko raised a rare yet valid case where quoted string ends with I see some ways out:
Despite being lazy, ignoring the possible error might be a better solution. |
I'll merge this for now. Additional ideas can be implemented in future PRs. |
This should take care of #2664.
@r888888888 requesting code review. I don't think it would break anything, it simply extracts
source:"..."
verbatim from tag string before splitting the rest on spaces. I have two concerns about other code, though:.gsub(/[%,]/, "")
inTag.scan_tags
? I put source extraction before it, since I figured that source can contain commas and percents.source:none
will set post source to nil.source:""
andsource:
will set it to empty string. Should something be done about that?