FriendsOfFlarum / webhooks

Flarum with outgoing webhooks
MIT License
21 stars 12 forks source link

Microsoft Teams url validation #45

Closed antoinebidault closed 3 years ago

antoinebidault commented 3 years ago

Bug Report

Current Behavior I am not able to validate the current Microsoft Teams webhook url. The webhook url format has probably changed, the url format is looking like this : https://**{my organization name}.webhook.office.com/webhookb2**/ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ@ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ/IncomingWebhook/ZZZZZZZZZZZZZZZ/ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ

Curiously if i change this url to https://**outlook**.office.com/**webhook**/ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ@ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ/IncomingWebhook/ZZZZZZZZZZZZZZZ/ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ It's working.

Steps to Reproduce

  1. Go to webhook config
  2. Setup a webhook connectors in Microsoft teams group
  3. Paste the url in the webhook config input

Expected Behavior The webhook url provided by teams might be validated.

Screenshots image

Environment FreeFlarum.com

Possible solution(s)

The regex in that file might be improved or changed: https://github.com/FriendsOfFlarum/webhooks/blob/master/src/Adapters/MicrosoftTeams/Adapter.php

I am not an expert in regex, but maybe this one will cover both the old and the new webhook url version : *^https:\/\/[a-z-_.+].office.com\/webhook(b2)?\/\S+@\S+\/IncomingWebhook\/\S+\/\S+$**

See the example with both url : https://regex101.com/r/VJgCJd/1

Hope that helps. Thanks a lot for maintaining this project !

dsevillamartin commented 3 years ago

Thanks a lot for maintaining this project !

No problem! Should be fixed in v1.0.5 - went with \S for the part before office just to keep in consistent & not restrict based on other potential characters.