Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Lynchburg Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lynchburg
Lynchburg Server
Commits
636f13bc
Commit
636f13bc
authored
4 years ago
by
Nils G.
Browse files
Options
Downloads
Patches
Plain Diff
Add definition rule for input field maxlength. Enforce on Client and Server side
parent
b8962e21
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controllers/player.py
+12
-0
12 additions, 0 deletions
controllers/player.py
static/game/debug/renderer.js
+4
-0
4 additions, 0 deletions
static/game/debug/renderer.js
with
16 additions
and
0 deletions
controllers/player.py
+
12
−
0
View file @
636f13bc
...
...
@@ -79,6 +79,15 @@ def submit():
new_input
=
{
"
submit
"
:
parameters
[
"
submit
"
]}
if
JSON_CONTAINS
(
parameters
,
[(
'
inputs
'
,
dict
)]):
#Load role definitions for additional validation (e.g. maxlength)
elements
=
B64_TO_JSON
(
room_record
.
roles
)[
player_record
.
role
][
"
elements
"
]
input_definitions
=
{}
for
element
in
elements
:
if
element
[
"
type
"
]
==
"
input
"
:
input_definitions
[
element
[
"
name
"
]]
=
element
inputs
=
parameters
[
"
inputs
"
]
for
key
in
inputs
:
...
...
@@ -87,6 +96,9 @@ def submit():
if
(
not
isinstance
(
inputs
[
key
],
str
))
or
(
keytest
!=
key
):
return
(
FAIL
(
CODE_MISSING
))
if
input_definitions
[
key
][
"
length
"
]
and
len
(
inputs
[
key
])
>
input_definitions
[
key
][
"
length
"
]:
return
(
FAIL
(
CODE_MISSING
))
inputs
[
key
]
=
''
.
join
(
c
for
c
in
inputs
[
key
]
if
(
c
.
isalnum
()
or
c
==
"
"
))
new_input
[
"
inputs
"
]
=
inputs
...
...
This diff is collapsed.
Click to expand it.
static/game/debug/renderer.js
+
4
−
0
View file @
636f13bc
...
...
@@ -63,6 +63,7 @@ function renderRole(_definition, _roleIdle) {
var
c
=
element
[
"
class
"
];
var
name
=
element
[
"
name
"
];
var
value
=
element
[
"
value
"
];
var
length
=
element
[
"
length
"
];
if
(
prompt
){
for
(
var
varname
in
prompt
){
...
...
@@ -81,6 +82,9 @@ function renderRole(_definition, _roleIdle) {
case
"
input
"
:
e
=
$
(
"
<input class='game_input' type='text'/>
"
);
e
.
attr
(
"
placeholder
"
,
value
);
if
(
length
)
{
e
.
attr
(
"
maxlength
"
,
length
);
}
if
(
!
prompt
)
{
e
.
attr
(
"
disabled
"
,
"
true
"
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment