Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodlenet
MoodleNet Frontend
Commits
165ee20b
Commit
165ee20b
authored
Jun 01, 2020
by
aleclofabbro
Browse files
Merge branch 'fix/loose_email_and_domain_regex_validations' into develop
parents
0efde2a6
dc9cc58a
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/HOC/modules/ShareLink/shareLinkHOC.tsx
View file @
165ee20b
...
...
@@ -7,6 +7,7 @@ import { ShareLink } from 'ui/modules/ShareLink';
import
{
ShareResource
}
from
'
ui/modules/ShareLink/fetched
'
;
import
*
as
Yup
from
'
yup
'
;
import
{
i18n
}
from
'
context/global/localizationCtx
'
;
import
{
DOMAIN_REGEX
}
from
'
mn-constants
'
;
export
const
validationSchema
=
Yup
.
object
<
ShareResource
>
({
name
:
Yup
.
string
()
...
...
@@ -39,7 +40,9 @@ export const ShareLinkHOC: FC<ShareLinkHOC> = ({
const
{
current
:
urlValidationSchema
}
=
useRef
(
Yup
.
object
<
{
fetchUrl
:
string
}
>
({
fetchUrl
:
Yup
.
string
().
required
(
i18n
.
_
(
'
url is required
'
))
fetchUrl
:
Yup
.
string
()
.
matches
(
DOMAIN_REGEX
)
.
required
(
i18n
.
_
(
'
url is required
'
))
})
);
...
...
src/HOC/pages/settings/instance/InstanceSettingsSection.tsx
View file @
165ee20b
...
...
@@ -4,11 +4,10 @@ import { useInstanceRegistrationAllowLists } from 'fe/settings/instance/registra
import
{
useFormik
}
from
'
formik
'
;
import
*
as
Yup
from
'
yup
'
;
import
{
useFormikPage
}
from
'
fe/lib/helpers/usePage
'
;
import
{
DOMAIN_REGEX
}
from
'
mn-constants
'
;
export
const
withEmailDomainValidation
=
Yup
.
object
().
shape
({
domain
:
Yup
.
string
().
matches
(
/^
(?!
:
\/\/)([
a-zA-Z0-9-_
]
+
\.)
*
[
a-zA-Z0-9
][
a-zA-Z0-9-_
]
+
\.[
a-zA-Z
]{2,11}?
$/gim
)
domain
:
Yup
.
string
().
matches
(
DOMAIN_REGEX
)
});
export
interface
InstanceSettingsSection
{}
...
...
src/HOC/pages/settings/invites/InstanceInvitesSection.tsx
View file @
165ee20b
...
...
@@ -4,11 +4,12 @@ import { useInstanceRegistrationAllowLists } from 'fe/settings/instance/registra
import
{
useFormik
}
from
'
formik
'
;
import
*
as
Yup
from
'
yup
'
;
import
{
useFormikPage
}
from
'
fe/lib/helpers/usePage
'
;
import
{
EMAIL_REGEX
}
from
'
mn-constants
'
;
export
interface
InstanceInvitesSection
{}
export
const
withEmailValidation
=
Yup
.
object
().
shape
({
email
:
Yup
.
string
().
e
ma
il
(
)
email
:
Yup
.
string
().
ma
tches
(
EMAIL_REGEX
)
});
export
const
InstanceInvitesSection
:
FC
<
InstanceInvitesSection
>
=
()
=>
{
...
...
src/HOC/pages/settings/preferences/PreferencesSettingsSection.tsx
View file @
165ee20b
...
...
@@ -3,9 +3,10 @@ import Preferences, { EditPreferences } from 'ui/pages/settings/preferences';
import
{
useFormik
}
from
'
formik
'
;
import
{
useProfile
}
from
'
fe/user/profile/useProfile
'
;
import
*
as
Yup
from
'
yup
'
;
import
{
DOMAIN_REGEX
}
from
'
mn-constants
'
;
const
validationSchema
=
Yup
.
object
<
EditPreferences
>
({
moodleWebsite
:
Yup
.
string
().
url
(
)
moodleWebsite
:
Yup
.
string
().
matches
(
DOMAIN_REGEX
)
});
export
const
PreferencesSettingsSection
:
FC
=
()
=>
{
...
...
src/fe/lib/moodleLMS/LMSPrefsPanel.tsx
View file @
165ee20b
...
...
@@ -6,6 +6,7 @@ import {
}
from
'
ui/modules/MoodlePanel
'
;
import
*
as
Yup
from
'
yup
'
;
import
Maybe
from
'
graphql/tsutils/Maybe
'
;
import
{
DOMAIN_REGEX
}
from
'
mn-constants
'
;
export
interface
LMSPrefsPanel
{
done
():
unknown
;
...
...
@@ -17,7 +18,7 @@ export interface LMSPrefsPanel {
}
const
validationSchema
=
Yup
.
object
<
BasicMoodleLMSConfigFormValues
>
({
site
:
Yup
.
string
()
.
url
(
)
.
matches
(
DOMAIN_REGEX
)
.
required
()
});
export
const
LMSPrefsPanel
:
FC
<
LMSPrefsPanel
>
=
({
...
...
src/fragmentTypes.json
View file @
165ee20b
{
"__schema"
:{
"types"
:[{
"kind"
:
"UNION"
,
"name"
:
"ActivityContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Flag"
},{
"name"
:
"Follow"
},{
"name"
:
"Like"
},{
"name"
:
"Resource"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"FeatureContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Community"
}]},{
"kind"
:
"UNION"
,
"name"
:
"LikeContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Resource"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"DeleteContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Feature"
},{
"name"
:
"Flag"
},{
"name"
:
"Follow"
},{
"name"
:
"Like"
},{
"name"
:
"Resource"
},{
"name"
:
"Thread"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"FollowContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Community"
},{
"name"
:
"Thread"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"ThreadContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Community"
},{
"name"
:
"Flag"
},{
"name"
:
"Resource"
}]},{
"kind"
:
"UNION"
,
"name"
:
"FlagContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Resource"
},{
"name"
:
"User"
}]}]}}
\ No newline at end of file
{
"__schema"
:{
"types"
:[{
"kind"
:
"UNION"
,
"name"
:
"ActivityContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Flag"
},{
"name"
:
"Follow"
},{
"name"
:
"Like"
},{
"name"
:
"Resource"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"FollowContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Community"
},{
"name"
:
"Thread"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"FlagContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Resource"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"FeatureContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Community"
}]},{
"kind"
:
"UNION"
,
"name"
:
"DeleteContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Feature"
},{
"name"
:
"Flag"
},{
"name"
:
"Follow"
},{
"name"
:
"Like"
},{
"name"
:
"Resource"
},{
"name"
:
"Thread"
},{
"name"
:
"User"
}]},{
"kind"
:
"UNION"
,
"name"
:
"ThreadContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Community"
},{
"name"
:
"Flag"
},{
"name"
:
"Resource"
}]},{
"kind"
:
"UNION"
,
"name"
:
"LikeContext"
,
"possibleTypes"
:[{
"name"
:
"Collection"
},{
"name"
:
"Comment"
},{
"name"
:
"Community"
},{
"name"
:
"Resource"
},{
"name"
:
"User"
}]}]}}
\ No newline at end of file
src/mn-constants.tsx
View file @
165ee20b
...
...
@@ -87,10 +87,8 @@ export const mothershipCreds =
export
const
searchDisabled
=
!
mothershipCreds
;
export
const
USERNAME_REGEX
=
/^
[
a-zA-Z
][
a-zA-Z0-9-
]{2,}
$/
;
export
const
max_file_size
=
'
10MB
'
;
export
const
accepted_file_types
=
'
.pdf, .rtf, .docx, .doc, .odt, .ott, .xls, .xlsx, .ods, .ots, .csv, .ppt, .pps, .pptx, .odp, .otp, .odg, .otg, .odc, .ogg, .mp3, .flac, .m4a, .wav, .mp4, .mkv, .flv, .avi, .gif, .jpg, .jpeg, .png, .svg, .webm, .eps, .tex, .mbz
'
;
export
const
EMAIL_REGEX
=
/^.+@.+
\.
.+$/
;
export
const
DOMAIN_REGEX
=
/^.+
\.
.+$/
;
// these licenses must match the icons (in the same order) configured in the UploadResource UI module
// please use standard identifiers from https://spdx.org/licenses/preview/ in order to preserve interoperability
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment