Skip to content

Commit a4f7649

Browse files
committed
🥅 Validate and send STORE attr as an atom
Previously, `#store` and `#uid_store` wrapped `attr` with `RawData`. But that's completely unnecessary. `+`, `-`, and `.` are atom chars, and every STORE "message data item" defined in any RFC is an `atom`: ``` FLAGS FLAGS.SILENT +FLAGS +FLAGS.SILENT -FLAGS -FLAGS.SILENT ANNOTATION ANNOTATION.SILENT ``` We can revisit this in the future, if some new extension uses a non-atom for its STORE "message data item", but that seems unlikely. Note also that `Atom` is only applied to `String` arguments.
1 parent 9db3e9d commit a4f7649

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/net/imap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3786,7 +3786,7 @@ def fetch_internal(cmd, set, attr, mod = nil, partial: nil, changedsince: nil)
37863786
end
37873787

37883788
def store_internal(cmd, set, attr, flags, unchangedsince: nil)
3789-
attr = RawData.new(attr) if attr.instance_of?(String)
3789+
attr = Atom.new(attr) if attr.instance_of?(String)
37903790
args = [SequenceSet.new(set)]
37913791
args << ["UNCHANGEDSINCE", Integer(unchangedsince)] if unchangedsince
37923792
args << attr << flags

test/net/imap/test_imap_store.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class IMAPStoreTest < Net::IMAP::TestCase
7272
test "#uid_store with changedsince" do
7373
with_fake_server select: "inbox" do |server, imap|
7474
server.on("UID STORE", &:done_ok)
75-
imap.uid_store 1..-1, "FLAGS", %i[Deleted], unchangedsince: 987
75+
imap.uid_store 1..-1, "+FLAGS.SILENT", %i[Deleted], unchangedsince: 987
7676
assert_equal(
77-
"RUBY0002 UID STORE 1:* (UNCHANGEDSINCE 987) FLAGS (\\Deleted)",
77+
"RUBY0002 UID STORE 1:* (UNCHANGEDSINCE 987) +FLAGS.SILENT (\\Deleted)",
7878
server.commands.pop.raw.strip
7979
)
8080
end

0 commit comments

Comments
 (0)