File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1926,7 +1926,11 @@ def getquota(quota_root)
19261926 # Sends a {SETQUOTA command [RFC2087 §4.1]}[https://www.rfc-editor.org/rfc/rfc2087#section-4.1]
19271927 # along with the specified +quota_root+ and +storage_limit+. If
19281928 # +storage_limit+ is +nil+, resource limits are unset for that quota root.
1929- # Otherwise, it sets the +STORAGE+ resource limit.
1929+ # If +storage_limit+ is a number, it sets the +STORAGE+ resource limit.
1930+ #
1931+ # imap.setquota "#user/alice", 100
1932+ # imap.getquota "#user/alice"
1933+ # # => [#<struct Net::IMAP::MailboxQuota mailbox="#user/alice" usage=54 quota=100>]
19301934 #
19311935 # Typically one needs to be logged in as a server admin for this to work.
19321936 #
@@ -1942,11 +1946,11 @@ def getquota(quota_root)
19421946 # resource type.
19431947 def setquota ( quota_root , storage_limit )
19441948 if storage_limit . nil?
1945- list = '()'
1949+ list = [ ]
19461950 else
1947- list = '( STORAGE ' + storage_limit . to_s + ')'
1951+ list = [ " STORAGE" , NumValidator . coerce_number64 ( storage_limit ) ]
19481952 end
1949- send_command ( "SETQUOTA" , quota_root , RawData . new ( list ) )
1953+ send_command ( "SETQUOTA" , quota_root , list )
19501954 end
19511955
19521956 # Sends a {SETACL command [RFC4314 §3.1]}[https://www.rfc-editor.org/rfc/rfc4314#section-3.1]
Original file line number Diff line number Diff line change @@ -28,6 +28,15 @@ class IMAPQuotaTest < Net::IMAP::TestCase
2828 rcvd_cmd = server . commands . pop
2929 assert_equal "SETQUOTA" , rcvd_cmd . name
3030 assert_equal '"" ()' , rcvd_cmd . args
31+
32+ assert_raise_with_message ( Net ::IMAP ::DataFormatError ,
33+ "512.0 is not a valid number64" ) do
34+ imap . setquota "INBOX" , 512.0
35+ end
36+ assert_raise_with_message ( Net ::IMAP ::DataFormatError ,
37+ '"512 620" is not a valid number64' ) do
38+ imap . setquota "INBOX" , "512 620"
39+ end
3140 end
3241 end
3342end
You can’t perform that action at this time.
0 commit comments