Cleanup: simplify the link regex in Email.extractLink

Aperta Adatta ai principianti
#275 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
testing-qa

Direzione di ricerca

La regex è alla riga 70 di src/main/java/com/seleniumboot/email/Email.java, dentro Email.extractLink(...). Leggi prima i test esistenti di extractLink, poi riscrivi il pattern in modo che due parti qualsiasi non possano corrispondere agli stessi caratteri, mantenendo gli stili delle virgolette, l'ordine degli attributi e l'insensibilità alle maiuscole/minuscole. Fatto quando i test esistenti passano, un nuovo test con un corpo lungo pieno di molti tag <a e senza corrispondenze termina rapidamente, e mvn test passa.

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

Descrizione

good first issue

Part of the cleanup cycle from #251. SonarCloud rule java:S8786 flags the link-matching regex in Email.extractLink(...) for possible super-linear backtracking. Email bodies come from outside, so this one is worth fixing.

Where: src/main/java/com/seleniumboot/email/Email.java, line 70:

"<a[^>]+href=[\"']([^\"']+)[\"'][^>]*>(.*?)</a>"

The [^>]+ before href can overlap with the attribute that follows it.

Fix: rewrite it so no two parts can match the same characters. For example, match <a\b, then attributes that don't start with href, then the href. Or use a possessive / atomic group. Keep the behaviour: double or single quotes, other attributes before or after href, nested tags in the link text, case-insensitive.

Done when: the existing extractLink tests still pass, a new test covers a long body with many <a tags and no match (it must finish quickly), SonarCloud no longer flags the line, and mvn test passes.

Lingua principale
Java
Stelle
12
Fork
6
Merge medio
8h 58m
PR unite (30g)
63

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 seleniumboot/selenium-boot

Tutte le issue di seleniumboot/selenium-boot

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.