Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
BRIC
dokuwiki
Commits
7fa270bc
Unverified
Commit
7fa270bc
authored
6 years ago
by
Michael Große
Browse files
Options
Downloads
Patches
Plain Diff
feat(Form): add parameter to omit security token in forms
This is useful for anonymously useable forms, like the search.
parent
3286c65d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inc/Form/Form.php
+5
-2
5 additions, 2 deletions
inc/Form/Form.php
inc/Ui/Search.php
+1
-1
1 addition, 1 deletion
inc/Ui/Search.php
inc/template.php
+1
-1
1 addition, 1 deletion
inc/template.php
with
7 additions
and
4 deletions
inc/Form/Form.php
+
5
−
2
View file @
7fa270bc
...
...
@@ -24,8 +24,9 @@ class Form extends Element {
* Creates a new, empty form with some default attributes
*
* @param array $attributes
* @param bool $unsafe if true, then the security token is ommited
*/
public
function
__construct
(
$attributes
=
array
())
{
public
function
__construct
(
$attributes
=
array
()
,
$unsafe
=
false
)
{
global
$ID
;
parent
::
__construct
(
'form'
,
$attributes
);
...
...
@@ -49,7 +50,9 @@ class Form extends Element {
}
// add the security token by default
$this
->
setHiddenField
(
'sectok'
,
getSecurityToken
());
if
(
!
$unsafe
)
{
$this
->
setHiddenField
(
'sectok'
,
getSecurityToken
());
}
// identify this as a new form based form in HTML
$this
->
addClass
(
'doku_form'
);
...
...
This diff is collapsed.
Click to expand it.
inc/Ui/Search.php
+
1
−
1
View file @
7fa270bc
...
...
@@ -65,7 +65,7 @@ class Search extends Ui
{
global
$lang
,
$ID
,
$INPUT
;
$searchForm
=
(
new
Form
(
))
->
attrs
(
[
'method'
=>
'get'
])
->
addClass
(
'search-results-form'
);
$searchForm
=
(
new
Form
([
'method'
=>
'get'
]
,
true
)
)
->
addClass
(
'search-results-form'
);
$searchForm
->
setHiddenField
(
'do'
,
'search'
);
$searchForm
->
setHiddenField
(
'id'
,
$ID
);
$searchForm
->
setHiddenField
(
'sf'
,
'1'
);
...
...
This diff is collapsed.
Click to expand it.
inc/template.php
+
1
−
1
View file @
7fa270bc
...
...
@@ -667,7 +667,7 @@ function tpl_searchform($ajax = true, $autocomplete = true) {
'role'
=>
'search'
,
'class'
=>
'search'
,
'id'
=>
'dw__search'
,
]);
]
,
true
);
$searchForm
->
addTagOpen
(
'div'
)
->
addClass
(
'no'
);
$searchForm
->
setHiddenField
(
'do'
,
'search'
);
$searchForm
->
setHiddenField
(
'id'
,
$ID
);
...
...
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