forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix oppia#2584: Replace default text while inserting links with place…
…holder (oppia#6286) * Fixes oppia#2584: Replace default text while inserting links with placeholder * Making minor changes * Modifying backend test * Fixing e2e test errors * Making changes * Creating new html file for sanitized url * Adding validator to SanitizeUrl object * Adding spaces * Adding tests * Adding else statement * Replacing list_editor with sanitized_url_editor
- Loading branch information
1 parent
2812471
commit 9ed174b
Showing
7 changed files
with
81 additions
and
45 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
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
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
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
3 changes: 3 additions & 0 deletions
3
extensions/objects/templates/sanitized_url_editor_directive.html
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,3 @@ | ||
<schema-based-unicode-editor local-value="value" validators="SCHEMA.validators" | ||
ui-config="SCHEMA.ui_config"> | ||
</schema-based-unicode-editor> |
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
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 |
---|---|---|
|
@@ -581,3 +581,36 @@ def test_notification_email_list_validator(self): | |
invalid_vals = [[u'admin@oppia'], big_email_list, | ||
[u'[email protected]'], [u'[email protected]']] | ||
self.check_normalization(schema, mappings, invalid_vals) | ||
|
||
def test_sanitize_url(self): | ||
"""Tests that sanitize_url method correctly sanitizes a string | ||
representing a URL and raises error for invalid strings. | ||
""" | ||
sanitize_url = schema_utils.Normalizers.get('sanitize_url') | ||
self.assertEqual( | ||
sanitize_url('https://www.oppia.org/splash/'), | ||
'https://www.oppia.org/splash/') | ||
|
||
self.assertEqual( | ||
sanitize_url('http://www.oppia.org/splash/'), | ||
'http://www.oppia.org/splash/') | ||
|
||
self.assertEqual( | ||
sanitize_url('http://example.com/~path;parameters?q=arg#fragment'), | ||
'http://example.com/%7Epath%3Bparameters?q%3Darg#fragment') | ||
|
||
self.assertEqual(sanitize_url(''), '') | ||
|
||
# Raise AssertionError if string does not start with http:// or | ||
# https://. | ||
with self.assertRaisesRegexp( | ||
AssertionError, | ||
'Invalid URL: Sanitized URL should start with \'http://\' or' | ||
' \'https://\'; received oppia.org'): | ||
sanitize_url('oppia.org') | ||
|
||
with self.assertRaisesRegexp( | ||
AssertionError, | ||
'Invalid URL: Sanitized URL should start with \'http://\' or' | ||
' \'https://\'; received www.oppia.org'): | ||
sanitize_url('www.oppia.org') |