wordpress-mobile / AztecEditor-iOS

A reusable native iOS visual HTML text editor component.
Mozilla Public License 2.0
611 stars 146 forks source link

Prevent crash due to malformed data. #1369

Closed Roger-Blinto closed 2 months ago

Roger-Blinto commented 1 year ago

Happened in the wild when pasting bullet list copied from the very same view.

spongemook commented 1 year ago

unarchiveTopLevelObjectWithData was deprecated in iOS 12.0

suggest code

do {
    let attributedString = try NSKeyedUnarchiver.unarchivedObject(ofClass: NSAttributedString.self, from: data)
    return attributedString
} catch {
    debugPrint(error.localizedDescription)
    return nil
}
Roger-Blinto commented 1 year ago

@spongemook Sure, that is more future proof. I would have preferred it as a one-liner, as the original. The library is for iOS 11 and onwards. If that version is increased there will be one less thing to change. Not counting this commit, 12 other API:s deprecated in iOS 15 or earlier are being used. Considering the number of issues, non merged pull requests and recent commit frequency I would say the repository is close to being abandoned...

jkmassel commented 8 months ago

Hi @Roger-Blinto – sorry about the wait on this – we'd be happy to merge it, but it'd be really helpful to see a test case to go along with it that demonstrates the issue.

Roger-Blinto commented 2 months ago

Fixed in a similar way in the master. Not included in latest release yet.