KnugiHK / WhatsApp-Chat-Exporter

A customizable Android and iOS/iPadOS WhatsApp database parser that will give you the history of your WhatsApp conversations in HTML and JSON. Android Backup Crypt12, Crypt14, Crypt15, and new schema supported.
https://wts.knugi.dev/
MIT License
615 stars 87 forks source link

[BUG] URL generation bug, plus WORKAROUND #113

Closed code-consensus closed 1 week ago

code-consensus commented 2 months ago

Describe the bug The program makes URLs clickable as per #69 . However, there is a bug of sorts involving messages that involve new-lines inside the message, where the link includes text and <br> elements.

To Reproduce Steps to reproduce the behavior:

  1. With a message like: "https://example.com/webpage.html Hey check out this link"

  2. the generated HTML will look like: <a href="https://example.com/webpage.html<br>Hey" target="_blank">

  3. The same if there are two-new lines, you would get html like <a href="https://example.com/webpage.html<br><br>Hey">

Workaround The issue is caused by the <br> insertions in the if "\r\n" in msg: and if "\n" in msg: sections in android_handler.py (line 446 and 461).

If you comment out those code segments to NOT add <br>, then the URLs are handled correctly (e.g. <a href="https://example.com/webpage.html">). However, that is at the expense of not creating a new line.

There must be some incompatibility with the addition of the <br> elements to the message and the subsequent "urlification" of the message in create_html() (the urlize() function in whatsapp.html?)

KnugiHK commented 1 month ago

The issue should be resolved in commit f35bf24 by adding a space before the <br> tag, although it is essentially an alteration to the message.

To (if) any forensic investigators: please use the god damn paid tools like EnCase and FTK or whatever.

code-consensus commented 1 month ago

I tested this myself, and seems to work perfectly now. As for the message being slightly "altered", that is a small price to pay to have the message show up correctly!

The issue should be resolved in commit f35bf24 by adding a space before the <br> tag, although it is essentially an alteration to the message.

To (if) any forensic investigators: please use the god damn paid tools like EnCase and FTK or whatever.

KnugiHK commented 1 week ago

Released in 0.10.5.