Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Proxy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
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
Show more breadcrumbs
open-source
Proxy
Commits
9c728409
Commit
9c728409
authored
2 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Patches
Plain Diff
fixed error on a tags with download attribute
parent
6280cb20
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
proxy/app/HtmlDocument.php
+10
-8
10 additions, 8 deletions
proxy/app/HtmlDocument.php
with
10 additions
and
8 deletions
proxy/app/HtmlDocument.php
+
10
−
8
View file @
9c728409
...
...
@@ -3,6 +3,7 @@
namespace
App
;
use
DomDocument
;
use
DOMElement
;
class
HtmlDocument
extends
Document
{
...
...
@@ -35,7 +36,6 @@ class HtmlDocument extends Document
if
(
$encoding
!==
null
)
{
break
;
}
}
# If there is a Charset Meta Tag
if
(
$meta
->
hasAttribute
(
"charset"
))
{
...
...
@@ -93,6 +93,7 @@ class HtmlDocument extends Document
}
# First things first. Let's change all a Tags that can define a target Attribute
/** @var DOMElement */
foreach
(
$dom
->
getElementsByTagName
(
'a'
)
as
$link
)
{
if
(
$link
->
hasAttribute
(
"href"
))
{
if
(
stripos
(
$link
->
getAttribute
(
"href"
),
"#"
)
===
0
)
{
...
...
@@ -109,7 +110,11 @@ class HtmlDocument extends Document
$link
->
setAttribute
(
"href"
,
$this
->
proxifyUrl
(
$link
->
getAttribute
(
"href"
),
true
));
}
}
# A tags might have a download attribute defined. Downloads are handled by the proxy
# In another way so we need to remove those attributes if present
if
(
$link
->
hasAttribute
(
"download"
))
{
$link
->
removeAttribute
(
"download"
);
}
}
# All Buttons
...
...
@@ -137,7 +142,6 @@ class HtmlDocument extends Document
# And replace
$button
->
setAttribute
(
"href"
,
$href
);
}
}
foreach
(
$dom
->
getElementsByTagName
(
'area'
)
as
$area
)
{
...
...
@@ -278,7 +282,6 @@ class HtmlDocument extends Document
$img
->
setAttribute
(
"src"
,
$this
->
convertRelativeToAbsoluteLink
(
$img
->
getAttribute
(
"src"
)));
# Convert all Image Sources to proxified Versions
$img
->
setAttribute
(
"src"
,
$this
->
proxifyUrl
(
$img
->
getAttribute
(
"src"
),
false
));
}
# Some Images might contain a srcset (Different Images for different resolutions)
# Syntax would be i.e. srcset="medium.jpg 1000w, large.jpg 2000w"
...
...
@@ -397,12 +400,11 @@ class HtmlDocument extends Document
libxml_use_internal_errors
(
false
);
}
/**
* This function changes the current Target Attribute on the link to given new target Attribute
*/
/**
* This function changes the current Target Attribute on the link to given new target Attribute
*/
private
function
convertTargetAttribute
(
$link
,
$newTarget
)
{
$link
->
setAttribute
(
"target"
,
$newTarget
);
}
}
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