Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from main (production) #1408

Merged
merged 3 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/sync_nutmeg_with_juniper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: pull-request-action
uses: vsoch/pull-request-action@1.0.19
uses: vsoch/pull-request-action@1.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: "main"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sync_prod_with_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: pull-request-action
uses: vsoch/pull-request-action@1.0.19
uses: vsoch/pull-request-action@1.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH_PREFIX: "main"
PULL_REQUEST_BRANCH: "prod"
PULL_REQUEST_TITLE: "Update from `main` (production)"
PULL_REQUEST_REVIEWERS: "xscrio amirtds bryanlandia"
PULL_REQUEST_REVIEWERS: "VladyslavTy daniilly"
20 changes: 20 additions & 0 deletions common/djangoapps/student/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,27 @@ def sanitize_next_parameter(next_param):
return next_param

if COURSE_URL_PATTERN.match(next_param):
# Sometimes the course id received with incorrect encoding/decoding, we need to
# replace it to the correct pattern:
# course-v1:test-sandbox PREP-CORE C -> course-v1:test-sandbox+PREP-CORE+C
#
# Note: We are not expect to have any spaces in course URL

if ' ' in next_param:
next_param = next_param.replace(' ', '+')
elif '%20' in next_param:
next_param = next_param.replace('%20', '+')

sanitized_next_parameter = re.sub(r'\+', '%2B', next_param)

log.info(
u"The course-like next parameter was detected '%(next_param)s'"
u" this will be replaced with sanitized version: '%(sanitized_next_parameter)s'",
{
"next_param": next_param,
"sanitized_next_parameter": sanitized_next_parameter,
}
)
return sanitized_next_parameter

return next_param
24 changes: 24 additions & 0 deletions common/djangoapps/student/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,27 @@ def test_sanitize_next_param(self):
# Invalid pattern - keep the next_param as it is
next_param = 'some/other/path'
self.assertEqual(sanitize_next_parameter(next_param), next_param)

# Invalid URL with space - replace the ' ' with '+' and encode it
expected_result = 'courses/course-v1:abc-sandbox%2BACC-PTF%2BC/course'

next_param = 'courses/course-v1:abc-sandbox ACC-PTF C/course'
self.assertEqual(sanitize_next_parameter(next_param), expected_result)

next_param = 'courses/course-v1:abc-sandbox ACC-PTF+C/course'
self.assertEqual(sanitize_next_parameter(next_param), expected_result)

next_param = 'courses/course-v1:abc-sandbox+ACC-PTF C/course'
self.assertEqual(sanitize_next_parameter(next_param), expected_result)

# Invalid URL with encoded space - replace the '%20' with '+' and encode it
expected_result = 'courses/course-v1:abc-sandbox%2BACC-PTF%2BC/course'

next_param = 'courses/course-v1:abc-sandbox%20ACC-PTF%20C/course'
self.assertEqual(sanitize_next_parameter(next_param), expected_result)

next_param = 'courses/course-v1:abc-sandbox%20ACC-PTF+C/course'
self.assertEqual(sanitize_next_parameter(next_param), expected_result)

next_param = 'courses/course-v1:abc-sandbox+ACC-PTF%20C/course'
self.assertEqual(sanitize_next_parameter(next_param), expected_result)
Loading