Merge commit '7c4c2de7a08bedacd2e53864957a5cbca8863b77' into jalkut-skip-mode

This commit is contained in:
Daniel Jalkut 2020-11-01 17:42:03 -05:00
commit c9de1c691a
2 changed files with 25 additions and 14 deletions

View File

@ -299,6 +299,10 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
group.notify(queue: DispatchQueue.main) {
if self.variant == .theOldReader {
account.removeFolder(folder)
completion(.success(()))
} else {
self.caller.deleteTag(folder: folder) { result in
switch result {
case .success:
@ -309,6 +313,7 @@ final class ReaderAPIAccountDelegate: AccountDelegate {
}
}
}
}
}
@ -858,7 +863,7 @@ private extension ReaderAPIAccountDelegate {
switch result {
case .success:
if let name = name {
account.renameWebFeed(feed, to: name) { result in
self.renameWebFeed(for: account, with: feed, to: name) { result in
switch result {
case .success:
self.initialFeedDownload(account: account, feed: feed, completion: completion)

View File

@ -83,6 +83,7 @@ final class ReaderAPICaller: NSObject {
var urlHostAllowed = CharacterSet.urlHostAllowed
urlHostAllowed.remove("+")
urlHostAllowed.remove("&")
uriComponentAllowed = urlHostAllowed
super.init()
}
@ -387,10 +388,10 @@ final class ReaderAPICaller: NSObject {
request.httpMethod = "POST"
var postString = "T=\(token)&ac=subscribe&s=\(streamId)"
if let folder = folder {
postString += "&a=user/-/label/\(folder.nameForDisplay)"
if let folderName = self.encodeForURLPath(folder?.nameForDisplay) {
postString += "&a=user/-/label/\(folderName)"
}
if let name = name {
if let name = self.encodeForURLPath(name) {
postString += "&t=\(name)"
}
@ -508,8 +509,12 @@ final class ReaderAPICaller: NSObject {
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"
let tagName = "user/-/label/\(tagName)"
let postData = "T=\(token)&s=\(subscriptionID)&ac=edit&a=\(tagName)".data(using: String.Encoding.utf8)
guard let tagName = self.encodeForURLPath(tagName) else {
completion(.failure(ReaderAPIAccountDelegateError.invalidParameter))
return
}
let postData = "T=\(token)&s=\(subscriptionID)&ac=edit&a=user/-/label/\(tagName)".data(using: String.Encoding.utf8)
self.transport.send(request: request, method: HTTPMethod.post, payload: postData!, completion: { (result) in
switch result {
@ -750,7 +755,8 @@ final class ReaderAPICaller: NSObject {
private extension ReaderAPICaller {
func encodeForURLPath(_ pathComponent: String) -> String? {
func encodeForURLPath(_ pathComponent: String?) -> String? {
guard let pathComponent = pathComponent else { return nil }
return pathComponent.addingPercentEncoding(withAllowedCharacters: uriComponentAllowed)
}