Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ARSnova Backend
Manage
Activity
Members
Labels
Plan
Issues
27
Issue boards
Milestones
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Privacy
Imprint
Contact
Snippets
Groups
Projects
Show more breadcrumbs
ARSnova
ARSnova Backend
Commits
e0abbeca
There was a problem fetching the latest pipeline status.
Commit
e0abbeca
authored
9 years ago
by
Andreas Gärtner
Browse files
Options
Downloads
Patches
Plain Diff
Task #17566: Prevent image base64 encoding for URIs
parent
e196c37f
No related merge requests found
Pipeline
#209
passed with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/thm/arsnova/services/QuestionService.java
+2
-10
2 additions, 10 deletions
src/main/java/de/thm/arsnova/services/QuestionService.java
with
2 additions
and
10 deletions
src/main/java/de/thm/arsnova/services/QuestionService.java
+
2
−
10
View file @
e0abbeca
...
...
@@ -112,15 +112,7 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis
}
// convert imageurl to base64 if neccessary
if
(
"grid"
.
equals
(
question
.
getQuestionType
()))
{
if
(
question
.
getImage
().
startsWith
(
"http"
))
{
final
String
base64ImageString
=
imageUtils
.
encodeImageToString
(
question
.
getImage
());
if
(
base64ImageString
==
null
)
{
throw
new
BadRequestException
();
}
question
.
setImage
(
base64ImageString
);
}
if
(
"grid"
.
equals
(
question
.
getQuestionType
())
&&
!
question
.
getImage
().
startsWith
(
"http"
))
{
// base64 adds offset to filesize, formula taken from: http://en.wikipedia.org/wiki/Base64#MIME
final
int
fileSize
=
(
int
)
((
question
.
getImage
().
length
()
-
814
)
/
1.37
);
if
(
fileSize
>
uploadFileSizeByte
)
{
...
...
@@ -827,7 +819,7 @@ public class QuestionService implements IQuestionService, ApplicationEventPublis
@PreAuthorize
(
"isAuthenticated()"
)
public
List
<
Question
>
replaceImageData
(
final
List
<
Question
>
questions
)
{
for
(
Question
q
:
questions
)
{
if
(
q
.
getImage
()
!=
null
)
{
if
(
q
.
getImage
()
!=
null
&&
q
.
getImage
().
startsWith
(
"data:image/"
)
)
{
q
.
setImage
(
"true"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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