Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nextcloud mail - PostGuard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
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
Laura Kolijn
Nextcloud mail - PostGuard
Commits
c6aceeef
Commit
c6aceeef
authored
9 years ago
by
Jakob Sack
Browse files
Options
Downloads
Patches
Plain Diff
Block external images
parent
53941001
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
img/blocked-image.png
+0
-0
0 additions, 0 deletions
img/blocked-image.png
lib/service/html.php
+4
-0
4 additions, 0 deletions
lib/service/html.php
lib/service/htmlpurify/transformimagesrc.php
+29
-0
29 additions, 0 deletions
lib/service/htmlpurify/transformimagesrc.php
with
33 additions
and
0 deletions
img/blocked-image.png
0 → 100644
+
0
−
0
View file @
c6aceeef
180 B
This diff is collapsed.
Click to expand it.
lib/service/html.php
+
4
−
0
View file @
c6aceeef
...
...
@@ -19,6 +19,7 @@ use HTMLPurifier_HTMLDefinition;
use
HTMLPurifier_URISchemeRegistry
;
use
Kwi\UrlLinker
;
use
OCA\Mail\Service\HtmlPurify\CidURIScheme
;
use
OCA\Mail\Service\HtmlPurify\TransformImageSrc
;
use
OCA\Mail\Service\HtmlPurify\TransformNoReferrer
;
use
OCA\Mail\Service\HtmlPurify\TransformURLScheme
;
use
OCP\IURLGenerator
;
...
...
@@ -95,6 +96,9 @@ class Html {
$config
->
set
(
'Cache.DefinitionImpl'
,
null
);
// Rewrite URL for redirection and proxying of content
$html
=
$config
->
getDefinition
(
'HTML'
);
$html
->
info_attr_transform_post
[
'imagesrc'
]
=
new
TransformImageSrc
();
$uri
=
$config
->
getDefinition
(
'URI'
);
$uri
->
addFilter
(
new
TransformURLScheme
(
$messageParameters
,
$mapCidToAttachmentId
,
$this
->
urlGenerator
),
$config
);
...
...
This diff is collapsed.
Click to expand it.
lib/service/htmlpurify/transformimagesrc.php
0 → 100644
+
29
−
0
View file @
c6aceeef
<?php
namespace
OCA\Mail\Service\HtmlPurify
;
use
HTMLPurifier_AttrTransform
;
use
HTMLPurifier_Config
;
use
HTMLPurifier_Context
;
use
OCP\Util
;
/**
* Adds copies src to data-src on all img tags.
*/
class
TransformImageSrc
extends
HTMLPurifier_AttrTransform
{
/**
* @param array $attr
* @param HTMLPurifier_Config $config
* @param HTMLPurifier_Context $context
* @return array
*/
public
function
transform
(
$attr
,
$config
,
$context
)
{
if
(
$context
->
get
(
'CurrentToken'
)
->
name
!==
'img'
||
!
isset
(
$attr
[
'src'
]))
{
return
$attr
;
}
$attr
[
'data-original-src'
]
=
$attr
[
'src'
];
$attr
[
'src'
]
=
Util
::
imagePath
(
'mail'
,
'blocked-image.png'
);
return
$attr
;
}
}
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