Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vtigercrm
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
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
Admin message
Welcome to Vtiger Community. To gain access for account, please contact [ community @ vtiger.com ]
Show more breadcrumbs
Code80
vtigercrm
Commits
1c70c7bb
Commit
1c70c7bb
authored
4 years ago
by
Uma
Browse files
Options
Downloads
Patches
Plain Diff
Fixes cleaning up text data for vulnerable code
parent
c874561f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/utils/VtlibUtils.php
+11
-3
11 additions, 3 deletions
include/utils/VtlibUtils.php
layouts/v7/modules/Vtiger/uitypes/Text.tpl
+4
-2
4 additions, 2 deletions
layouts/v7/modules/Vtiger/uitypes/Text.tpl
modules/Vtiger/uitypes/Text.php
+9
-2
9 additions, 2 deletions
modules/Vtiger/uitypes/Text.php
with
24 additions
and
7 deletions
include/utils/VtlibUtils.php
+
11
−
3
View file @
1c70c7bb
...
...
@@ -724,11 +724,19 @@ function purifyHtmlEventAttributes($value,$replaceAll = false){
// remove malicious html attributes with its value.
if
(
$replaceAll
)
{
//Handled to address multiple html entity encoding for '=' character
$regex
=
'\s*(=|=|=|=|=)\s*(?:"[^"]*"[\'"]*|\'[^\']*\'[\'"]*|[^]*[\s\/>])*/i'
;
$regex
=
'\s*[=&%#]\s*(?:"[^"]*"[\'"]*|\'[^\']*\'[\'"]*|[^]*[\s\/>])*/i'
;
$value
=
preg_replace
(
"/\s*("
.
$htmlEventAttributes
.
")"
.
$regex
,
''
,
$value
);
/**
* #131224556::if anchor tag having 'javascript:' string then remove the tag contents.
* Right now, we fixed this for anchor tag as we don't see any other such things right now.
* All other event attributes are already handled above. Need to update this if any thing new found
*/
$javaScriptRegex
=
'/<a [^>]*(j[\s]?a[\s]?v[\s]?a[\s]?s[\s]?c[\s]?r[\s]?i[\s]?p[\s]?t[\s]*[=&%#:])[^>]*?>/i'
;
$value
=
preg_replace
(
$javaScriptRegex
,
'<a>'
,
$value
);
}
else
{
if
(
preg_match
(
"/\s*("
.
$htmlEventAttributes
.
")\s*
(=|=|&#61;|&#x26;#61;|&#61;)
/i"
,
$value
))
{
if
(
preg_match
(
"/\s*("
.
$htmlEventAttributes
.
")\s*
=
/i"
,
$value
))
{
$value
=
str_replace
(
"="
,
"="
,
$value
);
}
}
...
...
This diff is collapsed.
Click to expand it.
layouts/v7/modules/Vtiger/uitypes/Text.tpl
+
4
−
2
View file @
1c70c7bb
...
...
@@ -22,7 +22,8 @@
data-specific-rules=
'
{
ZEND_JSON
::
encode
(
$FIELD_INFO
[
"validator"
])
}
'
{/
if
}
>
{
$FIELD_MODEL
->
get
(
'fieldvalue'
)
}
</textarea>
{
purifyHtmlEventAttributes
(
$FIELD_MODEL
->
get
(
'fieldvalue'
),
true
)|
regex_replace
:
"/(?!\w)\ (?=\w)/"
:
" "
}
</textarea>
{
else
}
<textarea
rows=
"5"
id=
"
{
$MODULE
}
_editView_fieldName_
{
$FIELD_NAME
}
"
class=
"inputElement
{
if
$FIELD_MODEL
->
isNameField
()
}
nameField
{/
if
}
"
name=
"
{
$FIELD_NAME
}
"
{
if
!
empty
(
$SPECIAL_VALIDATOR
)
}
data-validator=
'
{
Zend_Json
::
encode
(
$SPECIAL_VALIDATOR
)
}
'
{/
if
}
{
if
$FIELD_INFO
[
"mandatory"
]
eq
true
}
data-rule-required=
"true"
{/
if
}
...
...
@@ -30,6 +31,7 @@
data-specific-rules=
'
{
ZEND_JSON
::
encode
(
$FIELD_INFO
[
"validator"
])
}
'
{/
if
}
>
{
$FIELD_MODEL
->
get
(
'fieldvalue'
)
}
</textarea>
{
purifyHtmlEventAttributes
(
$FIELD_MODEL
->
get
(
'fieldvalue'
),
true
)|
regex_replace
:
"/(?!\w)\ (?=\w)/"
:
" "
}
</textarea>
{/
if
}
{/
strip
}
This diff is collapsed.
Click to expand it.
modules/Vtiger/uitypes/Text.php
+
9
−
2
View file @
1c70c7bb
...
...
@@ -15,8 +15,15 @@ class Vtiger_Text_UIType extends Vtiger_Base_UIType {
* @param <Object> $value
* @return <Object>
*/
public
function
getDisplayValue
(
$value
,
$record
=
false
,
$recordInstance
=
false
)
{
return
nl2br
(
$value
);
public
function
getDisplayValue
(
$value
,
$record
=
false
,
$recordInstance
=
false
,
$removeTags
=
false
)
{
//This API replaces newlines to html br tags, and spaces with
// It should not replace spaces within html tags
$value
=
decode_html
(
preg_replace
(
'/\r\n|\r|\n|
|&NewLine;/'
,
'<br>'
,
$value
));
if
(
$removeTags
){
$value
=
strip_tags
(
$value
,
'<br>'
);
}
$value
=
purifyHtmlEventAttributes
(
$value
,
true
);
return
$value
;
}
/**
...
...
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