profile
viewpoint

stephencelis/SQLite.swift 6997

A type-safe, Swift-language layer over SQLite3.

jspahrsummers/the-future-of-reactivecocoa 75

Presentation for RACDC 2014

jlawton/UIColor-HTMLColors 41

Read and write HTML/CSS colors.

jspahrsummers/correct-behavior-through-type-safety 15

Talk about using types to prove correctness

jspahrsummers/pure-lua 9

Pure functional programming for Lua

jlawton/ObjectiveAvro 4

ObjectiveAvro is a wrapper on Avro-C, following the API conventions of Foundation's NSJSONSerialization.

evanmoran/composite 1

A compositor for canvas

evanmoran/queryfu 1

Abstract query syntax for ninjas

evanmoran/smite-client 1

Web development hammers for your browser

evanmoran/smite-db-mongoose 1

Smite db integration using mongoose

issue commentdandavison/delta

🐛 Crash searching a long diff

It looks like it's fixed on master! Thanks! The whole diff paged.

I'm impressed with how simple the whole installation of rust and the build was. Just another reminder I should give rust a try. A huge contrast to a ruby environment I had to set up the other day.

Of course, I also realized that the two behaviors I was seeing was probably an artifact of G causing a repaint, but a failed search causing a read without a repaint of the screen, letting stderr show.

jlawton

comment created time in a month

issue openeddandavison/delta

🐛 Crash searching a long diff

delta --version: 0.1.1 git config core.pager: delta --dark

I have a 25MB diff that unfortunately I can't share. It's a mixture of various code, XML, PDFs, etc. I'm sorry if that leaves this a little lean on detail. My main lead is that the diff has a lot of inexact renames, but that could be a red herring.

Two bad behaviors happen with delta.

  1. I can git show and hit G to jump to the end, I only get to line 184,066, with the rest of the diff cut off. The same with git show | less, I get to 547,184.

  2. If I kick off a search that doesn't match instead, I get an out of bounds error with the following trace:

thread 'main' panicked at 'byte index 2 is out of bounds of `&`', src/libcore/str/mod.rs:2131:9
stack backtrace:
   0:        0x10732cac5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h30b85a1761190f28
   1:        0x1073431ce - core::fmt::write::h5b0722e6ee659e34
   2:        0x10732bce9 - std::io::Write::write_fmt::hf468289e762fa2f9
   3:        0x10731d86a - std::panicking::default_hook::{{closure}}::h836d46ca6b872224
   4:        0x10731d58f - std::panicking::default_hook::h2afcf1998cd93f8c
   5:        0x10731de4d - std::panicking::rust_panic_with_hook::he4f5d8b43533efd5
   6:        0x10731da12 - rust_begin_unwind
   7:        0x10734f32f - core::panicking::panic_fmt::h3559129da805eab4
   8:        0x10734f0ae - core::str::slice_error_fail::hd6f6d2e5a693e978
   9:        0x1071d84c4 - core::str::traits::<impl core::slice::SliceIndex<str> for core::ops::range::Range<usize>>::index::{{closure}}::h24851af3c1dab157
  10:        0x1071da39f - delta::parse::get_file_extension_from_diff_line::h02d721288dfd8178
  11:        0x1071cd157 - delta::delta::delta::hef7771a97efa631e
  12:        0x1071d67fe - delta::main::hfdd82967b734b176
  13:        0x1071d7505 - std::rt::lang_start::{{closure}}::h5d2da361401c3ca8
  14:        0x10731d928 - std::panicking::try::do_call::h29bd6a8b4eb65398
  15:        0x10733025b - __rust_maybe_catch_panic
  16:        0x107322389 - std::rt::lang_start_internal::h1cbb853ed77189ce
  17:        0x1071d74d9 - main

The same with git show | less spits out the following (on stderr, CTRL-L repaints without the lines) but then G does get to the end of the diff.

warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your diff.renameLimit variable to at least 4020 and retry the command.

created time in a month

Pull request review commentbox/box-ios-sdk

Add path parameter sanitization

 extension URL {     }      private static func make(from string: String, relativeTo baseURL: URL) -> URL {+        let range = NSRange(location: 0, length: string.utf16.count)+        // Checks that url paths with relative paths like /../ are not sent to the API+        // swiftlint:disable:next force_try+        let regex = try! NSRegularExpression(pattern: "\\/\\.+\\/")+        if regex.firstMatch(in: string, options: [], range: range) != nil {+            fatalError("An invalid path parameter exists in \(string). Relative path parameters cannot be passed.")+        }

Do we want to search for any number of dots?

sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add path parameter sanitization

 extension URL {     }      private static func make(from string: String, relativeTo baseURL: URL) -> URL {+        let range = NSRange(location: 0, length: string.utf16.count)+        // Checks that url paths with relative paths like /../ are not sent to the API+        // swiftlint:disable:next force_try+        let regex = try! NSRegularExpression(pattern: "\\/\\.+\\/")+        if regex.firstMatch(in: string, options: [], range: range) != nil {+            fatalError("An invalid path parameter exists in \(string). Relative path parameters cannot be passed.")+        }

I think this would catch .. at the beginning and end of the string, which the current regex wouldn't.

sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add path parameter sanitization

 extension URL {     }      private static func make(from string: String, relativeTo baseURL: URL) -> URL {+        let range = NSRange(location: 0, length: string.utf16.count)+        // Checks that url paths with relative paths like /../ are not sent to the API+        // swiftlint:disable:next force_try+        let regex = try! NSRegularExpression(pattern: "\\/\\.+\\/")+        if regex.firstMatch(in: string, options: [], range: range) != nil {+            fatalError("An invalid path parameter exists in \(string). Relative path parameters cannot be passed.")+        }

This might be another formulation to consider.

        for c in string.components(separatedBy: "/") where c == ".." {
            fatalError("An invalid path parameter exists in \(string). Relative path parameters cannot be passed.")
        }
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add path parameter sanitization

 extension URL {     }      private static func make(from string: String, relativeTo baseURL: URL) -> URL {+        let range = NSRange(location: 0, length: string.utf16.count)

Maybe this will always be correct, but I believe the idiomatic way to do this is NSRange(string.startIndex ..< string.endIndex, in: string).

sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Use WKWebView for authorization

 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)                 }             });         }];-        return NO;-    } else if (![[[request URL] absoluteString] isEqualToString:[[request mainDocumentURL] absoluteString]]) {-        // If it is an iFrame, there's not much we can do. We have to just let the UIWebView do the load.-        // If we tried to use NSURLSession to make this request, we would not know how to properly populate the-        // iframe with the response.-        // This means we cannot handle scenarios such as:-        // a) The iFrame request requires HTTP Auth. We would normally want to pop up a custom dialog to collect credentials.-        // b) The iFrame request has an invalid SSL certificate. We would normally want to pop up a warning dialog and let the user decide what to do.-        return YES;-    } else if ([self webViewCanBeUsedDirectlyForHost:request.URL.host] == NO) {-        BOXLog(@"Was not authenticated, launching URLSession and not loading the request in the web view");-        [self.activityIndicator startAnimating];-        NSURLSessionDataTask *dataTask = [self.URLSession dataTaskWithRequest:request];-        [dataTask resume];-        BOXLog(@"URLSessionDataTask is %@", dataTask);-        return NO;+        decisionHandler(WKNavigationActionPolicyCancel);+        return;+    }+    if (@available(iOS 11.0, *)) {

I think the else is just to fall through.

jlawton

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add support for the classification field for Files and Folders

+//+//  Classification.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 5/1/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// Details about the classification applied to a Box file or folder+public class Classification: BoxInnerModel {+    // MARK: - Properties++    /// The color that is used to display the classification label in a user-interface+    public let color: String?

Or possibly providing an encoder/decoder. Because it may not be trivial to render this for users.

sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add support for the classification field for Files and Folders

+//+//  Classification.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 5/1/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// Details about the classification applied to a Box file or folder+public class Classification: BoxInnerModel {+    // MARK: - Properties++    /// The color that is used to display the classification label in a user-interface+    public let color: String?

This may be the representation we want in the interface, but I just want to ask if returning a system color object is interesting.

sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel uploads and downloads

+//+//  BoxNetworkTask.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 3/21/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// A Box network task request.+public class BoxNetworkTask {++    var task: URLSessionTask?

If we only ever use this for cancellation, and we don't expect task and nestedTask to be alive at the same time (I'm not sure this is true), and it's not part of the public interface, have we considered that we don't need the three task types, and we could get away with:

// This doesn't need to be public, and probably shouldn't be, as it shares a name with
// a protocol in Combine.
protocol Cancellable {
    func cancel()
}

public class BoxNetworkTask {
    private var task: Cancellable?
    // …
}

This would be forwards compatible with deciding to add subclasses in the future. Maybe we already know we'll want them?

sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel uploads and downloads

 public class FilesModule {     ///     can be uploaded and whether specified name is unique and won't cause conflicts.     ///   - completion: Returns a standard file object or an error if the parentId is invalid or if a file     ///     name collision occurs.+    /// - Returns: BoxUploadTask+    @discardableResult     public func upload(         data: Data,         name: String,         parentId: String,         progress: @escaping (Progress) -> Void = { _ in },         performPreflightCheck: Bool = false,         completion: @escaping Callback<File>-    ) {-        uploadWithPreflightCheck(-            performCheck: performPreflightCheck,-            name: name,-            size: Int64(data.count),-            parentId: parentId,-            request: { [weak self] in-                guard let self = self else {-                    return-                }-                self.upload(data: data, name: name, parentId: parentId, progress: progress, completion: completion)-            }, completion: completion+    ) -> BoxUploadTask {+        let task = BoxUploadTask()+        task.receiveTask(+            uploadWithPreflightCheck(+                performCheck: performPreflightCheck,+                name: name,+                size: Int64(data.count),+                parentId: parentId,+                request: { [weak self] in+                    guard let self = self else {+                        return+                    }

Is it expected that uploads don't make progress unless you retain the Files module?

sujaygarlanka

comment created time in 2 months

PR opened box/box-ios-sdk

Use WKWebView for authorization

Issue Link :link:

Use of UIWebView has become a problem when submitting to the Apple App Store. Mentioned in #669 and #647. This is an alternative to #710.

Goals :soccer:

  • Replace UIWebView with WKWebView for authorization.

Implementation Details :construction:

  • Swap in WKWebView.
  • Update delegate methods to support WKWebView.
  • Remove use of URLSession to load some requests, which was required when using UIWebView, but should no longer be.
  • Update Xcode projects according to Xcode's automatic fix suggestions.

Testing Details :mag:

  • Tested by running the Sample App and logging into Box, using the updated SDK.
+144 -259

0 comment

10 changed files

pr created time in 2 months

push eventbox/box-ios-sdk

James Lawton

commit sha dd611c51f991880178cb3f32f49137321fcdb64a

Sample app project updates.

view details

push time in 2 months

pull request commentbox/box-ios-sdk

switch UIWebView to WKWebView.

@OneSecure would you try running off the https://github.com/box/box-ios-sdk/tree/wkwebview-auth branch? I think it might be a cleaner change if it works for you.

OneSecure

comment created time in 2 months

push eventbox/box-ios-sdk

James Lawton

commit sha f096ef191472d980e33facb3c9ae010a0318fc76

Use WKWebView for login.

view details

James Lawton

commit sha 4b0e6c5f68b265ac488934649c6420cca5dd3290

MobileCoreServices was renamed CoreServices.

view details

push time in 2 months

create barnchbox/box-ios-sdk

branch : wkwebview-auth

created branch time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

+//+//  BoxNetworkTask.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 3/21/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// Represents Box Network Task request.+public class BoxNetworkTask {++    private var taskMethod: ((URLSessionTask) -> Void)?+    private var task: URLSessionTask?+    private var cancelBool: Bool+    +    /// Initializer+    init() {+        cancelBool = false+    }
    private var cancelled: Bool = false
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

+//+//  BoxDownloadTask.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 4/23/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// A Box network task returned for a download+public class BoxDownloadTask: BoxNetworkTask {+    /// Initializer+    override init() {+        super.init()+    }
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

 public class FilesModule {         fileId: String,         destinationURL: URL,         version: String? = nil,+        //        task: @escaping (URLSessionTask) -> Void = { _ in },
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

 extension BoxClient: BoxClientProtocol {         downloadDestinationURL: URL,         httpHeaders: BoxHTTPHeaders = [:],         queryParameters: QueryParameters = [:],+        task: @escaping (URLSessionTask) -> Void = { _ in },         progress: @escaping (Progress) -> Void = { _ in },         completion: @escaping Callback<BoxResponse>-    ) {+    ) -> BoxDownloadTask {+        let task = BoxDownloadTask()         send(             request: BoxRequest(                 httpMethod: .get,                 url: url,                 httpHeaders: httpHeaders,                 queryParams: queryParameters,                 downloadDestination: downloadDestinationURL,+                task: task.getTask(),
                task: task.receiveTask(_:),
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

+//+//  BoxNetworkTask.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 3/21/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// Represents Box Network Task request.+public class BoxNetworkTask {++    private var taskMethod: ((URLSessionTask) -> Void)?+    private var task: URLSessionTask?+    private var cancelBool: Bool+    +    /// Initializer+    init() {+        cancelBool = false+    }+}++extension BoxNetworkTask {+    internal func getTask() -> ((URLSessionTask) -> Void) {+        taskMethod = { sessionTask in+            if self.cancelBool {+                sessionTask.cancel()+            }+            else {+                self.task = sessionTask+            }+        }+        // swiftlint:disable:next force_unwrapping+        return taskMethod!+    }++    /// Method to cancel a network task+    public func cancel() {+        if let unwrappedTask = task {+            unwrappedTask.cancel()+        }+        else {+            cancelBool = true+        }
        task?.cancel()
        cancelled = true
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

+//+//  BoxNetworkTask.swift+//  BoxSDK-iOS+//+//  Created by Sujay Garlanka on 3/21/20.+//  Copyright © 2020 box. All rights reserved.+//++import Foundation++/// Represents Box Network Task request.+public class BoxNetworkTask {++    private var taskMethod: ((URLSessionTask) -> Void)?+    private var task: URLSessionTask?+    private var cancelBool: Bool+    +    /// Initializer+    init() {+        cancelBool = false+    }+}++extension BoxNetworkTask {+    internal func getTask() -> ((URLSessionTask) -> Void) {+        taskMethod = { sessionTask in+            if self.cancelBool {+                sessionTask.cancel()+            }+            else {+                self.task = sessionTask+            }+        }+        // swiftlint:disable:next force_unwrapping+        return taskMethod!+    }
    func receiveTask(_ sessionTask: URLSessionTask) {
        if self.cancelled {
            sessionTask.cancel()
        }
        else {
            self.task = sessionTask
        }
    }
sujaygarlanka

comment created time in 2 months

Pull request review commentbox/box-ios-sdk

Add ability to cancel downloads

 extension BoxClient: BoxClientProtocol {         downloadDestinationURL: URL,         httpHeaders: BoxHTTPHeaders = [:],         queryParameters: QueryParameters = [:],+        task: @escaping (URLSessionTask) -> Void = { _ in },

It seems like this is not used, and gets shadowed.

sujaygarlanka

comment created time in 2 months

more