-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Daniyal-Mackey <[email protected]>
- Loading branch information
Showing
1 changed file
with
13 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
``` |