Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`paragraphRange` signature does not specify the returning type could be nullable, leading to unexpected crashes

Aperta
#1,378 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
swift
Ambito
mobile-dev

Direzione di ricerca

Inizia in Aztec/Classes/Extensions/NSAttributedString+ParagraphRange.swift, in paragraphRange(for: NSTextAttachment), soprattutto nella chiamata a ranges(forAttachment:). Cerca i suoi chiamanti per capire come viene utilizzato il valore restituito, quindi verifica che il percorso in cui l’allegato non viene trovato non provochi più un arresto anomalo imprevisto e che i chiamanti interessati gestiscano il risultato in modo appropriato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[Type] Bug

We've seen some crashes in WooCommerce for iOS coming from our AztecEditor wrapper. This seems to come from the underlying usage of paragraphRange, since assumes that the attachment passed into the method is the string, force-unwrapping the first result of the attachments array:

    func paragraphRange(for attachment: NSTextAttachment) -> NSRange {
        // We assume the attachment IS in the string.  This method should not be called otherwise.
        let attachmentRange = ranges(forAttachment: attachment).first!
        
        return paragraphRange(for: attachmentRange)
    }

This leads to unexpected crashes when the method is not used as intended, since its signature does not specify that the result could be nil. Ideally we should change the returning type to NSRange?, or handle the existence of nil values internally.

Lingua principale
Swift
Stelle
667
Fork
153
Merge medio
2g 6h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wordpress-mobile/AztecEditor-iOS

Tutte le issue di wordpress-mobile/AztecEditor-iOS

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.