Crash CharacterReader.matchesAny(_:)
Hello, My app is crashing so many times. From Firebase Crashlytics I have this data:
Crashed: com.apple.main-thread 0 My App 0xe68318 CharacterReader.matchesAny(_:) + 20 (ParsingStrings.swift:20) 1 My App 0xf0ae80 Tokeniser.consumeCharacterReference(_:_:) + 189 (Tokeniser.swift:189) 2 My App 0xf0efe4 TokeniserState.read(_:_:) + 857 (TokeniserState.swift:857) 3 My App 0xeead64 specialized static Parser.parse(_:_:) + 47 (Tokeniser.swift:47) 4 My App 0xefcda8 parse(_:) + 70 (SwiftSoup.swift:70)
my code is:
let text: String = ......
let doc: Document = try SwiftSoup.parse(text)
let plainText = try doc.body()?.text()
I don't know the content of text and therefore I'm not able to replicate the problem. I am currently using version 2.11.1
I managed to replicate the crash with this String:
let text = "<a href='<"
As you can see it crashes
Task 3: Fatal error: Index out of range
SwiftSoup version 2.11.2
Thanks for the detailed report
If you can submit a fix PR, I can review and merge it. We are all volunteers here and I don't have time to investigate and fix this at the moment (and I work for myself so I don't have an employer to petition for company time to look into this either) but can assist you with contributing a resolution. Even if you have just a test case that reproduces the issue, that is helpful in reducing the work required to merge a fix.
Hello @aehlke,
I prepared the fix but I don't have permissions to push the code to a branch. Can you give me access or tell me how to open a PR? Thank you
Great thank you - https://github.com/scinfu/SwiftSoup/pulls and select 'New pull request' (green button), then select your fork
Hello @aehlke,
I created the PR https://github.com/scinfu/SwiftSoup/pull/357.
Thanks for the support.
Hello, My app is crashing so many times. From Firebase Crashlytics I have this data:
Crashed: com.apple.main-thread 0 My App 0xe68318 CharacterReader.matchesAny(_:) + 20 (ParsingStrings.swift:20) 1 My App 0xf0ae80 Tokeniser.consumeCharacterReference(_:_:) + 189 (Tokeniser.swift:189) 2 My App 0xf0efe4 TokeniserState.read(_:_:) + 857 (TokeniserState.swift:857) 3 My App 0xeead64 specialized static Parser.parse(_:_:) + 47 (Tokeniser.swift:47) 4 My App 0xefcda8 parse(_:) + 70 (SwiftSoup.swift:70)my code is:
let text: String = ......let doc: Document = try SwiftSoup.parse(text)let plainText = try doc.body()?.text()I don't know the content of text and therefore I'm not able to replicate the problem. I am currently using version 2.11.1
@DevOpsAppsIOL please update it should be fixed now