SMF icon indicating copy to clipboard operation
SMF copied to clipboard

Autolinker email with domain like properties

Open jdarwood007 opened this issue 2 years ago • 8 comments

Description

The autolinker is getting confused with domain looking names in email

Steps to reproduce

  1. Make a post with: [email protected]

Environment (complete as necessary)

  • Version/Git revision:
  • Database Type:
  • Database Version:
  • PHP Version:

Additional information/references

@Sesquipedalian I know you have done some work here regarding this. Seems like we may need to make the linker a bit more intelligent?

jdarwood007 avatar Jan 08 '23 17:01 jdarwood007

Also the autolinker doesn't match user:[email protected], but I think that is a edge case we don't need to solve.

Seems like we need to tell it to match the full thing if it sees a @ at the end and continue on. As well that app.info isn't a domain but the user portion of the email.

jdarwood007 avatar Jan 08 '23 17:01 jdarwood007

Currently we check for URLs before we check for email addresses. Switching the order of the tests would probably solve the first case. However, there might be unexpected side effects if we did that, so thorough testing would be needed.

Sesquipedalian avatar Jan 08 '23 17:01 Sesquipedalian

As for the second case, I don't think putting a colon in the local part of an email address is compliant with the relevant RFC documents. I'd need to double check that to be sure, but if I am correct then we are doing the right thing in the second case.

Sesquipedalian avatar Jan 08 '23 17:01 Sesquipedalian

Correction: a colon is allowed in the local part of an email address only if the local part is enclosed in double quotation marks. So in the case of user:[email protected], we are doing the right thing.

This does mean that, in theory, the autolinker should recognize email addresses in the form "user:password"@example.com. However, adding support for that would greatly complicate matters, and I strongly suspect that it would cause lots of false positives. I don't think we should do it.

Sesquipedalian avatar Jan 08 '23 18:01 Sesquipedalian

The colon separates the user and password for use with a link containing basic auth http link. Because of its lack of use, I was thinking it wasn't worth it. Just mentioned it. Is the email problem worth us risking it for 2.1? Your right we could create more BC by trying to fix this. I need to put together a document showing many auto linker cases so I can test this.

jdarwood007 avatar Jan 08 '23 18:01 jdarwood007

The colon separates the user and password for use with a link containing basic auth http link. Because of its lack of use, I was thinking it wasn't worth it. Just mentioned it.

Oh, I understand what the user:password format is typically used for in URIs. I'm just telling you what the RFCs say about what is and isn't valid. The form user:[email protected] is invalid. To include a colon in the local part, an email address must use the form "user:password"@example.com.

Is the email problem worth us risking it for 2.1? Your right we could create more BC by trying to fix this.

That's up to you guys, really.

I need to put together a document showing many auto linker cases so I can test this.

I have a test suite. I can share it later (busy now).

Sesquipedalian avatar Jan 08 '23 19:01 Sesquipedalian

@live627 also has a test suite. We have been meaning to get it setup officially. I just usually have a few text files I keep around for testing various post related stuff, as when I made converters or do other testing, I need to throw things at the parse_bbc logic.

jdarwood007 avatar Jan 08 '23 19:01 jdarwood007

This is based on the test data from @Sesquipedalian

https://github.com/live627/SMF2.1/blob/unittest/tests/BBCTest.php#L498-L711

live627 avatar Jan 09 '23 03:01 live627