Skip to content

Commit

Permalink
Add return url doc (#73)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniyal-Mackey <[email protected]>
  • Loading branch information
danyalmck and Daniyal-Mackey authored Sep 18, 2024
1 parent a3ecd88 commit dfa9c1e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions misc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### ریدایرکت لینک
در ریدایرکت کردن کاربر از دیوار به اپ های کنار دیوار از صفحه آگهی و مدیریت آگهی ، تعدادی پارامتر در لینک قرار میگیرد که یکی از این پارامتر ها `return_url` نام دارد. هدف این لینک بازگرداندن کاربر به دیوار است. اپ کنار دیوار موظف است پس از اتمام کار کاربر را به این لینک برگرداند.

نکته بسیار مهم این است که این عملیات ممکن است باعث [open redirection](https://learn.snyk.io/lesson/open-redirect/) یا حتی [xss](https://owasp.org/www-community/attacks/xss/) شود بنابراین حتما بررسی کنید که url داده شده برای دیوار باشد. تیکه کد زیر یک فانکشن جاوا اسکریپت است که با استفاده از regex این کار را انجام میدهد.
```js
function isDivarLink(link) {
// Define the regular expression for divar.ir and its subdomains
const divarRegex = /^https:\/\/(?:[a-zA-Z0-9-]+\.)?divar\.ir(\/?|\/.+)/;

// Test the link against the regular expression
return divarRegex.test(link);
}
```

0 comments on commit dfa9c1e

Please sign in to comment.