Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add Redirect from old icon endpoint [DHIS2-16042] #15802

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -56,6 +57,7 @@
import org.hisp.dhis.icon.IconService;
import org.hisp.dhis.schema.descriptors.IconSchemaDescriptor;
import org.hisp.dhis.webapi.mvc.annotation.ApiVersion;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.utils.HeaderUtils;
import org.springframework.core.io.Resource;
import org.springframework.http.CacheControl;
Expand Down Expand Up @@ -100,9 +102,11 @@
}

@GetMapping("/{iconKey}/icon.svg")
public void getIconData(HttpServletResponse response, @PathVariable String iconKey)
throws IOException, NotFoundException {
downloadDefaultIcon(iconKey, response);
public void getIconData(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also mark the endpoint as deprecated? or is it not necessary?

HttpServletResponse response, HttpServletRequest request, @PathVariable String iconKey)
throws IOException {
String location = response.encodeRedirectURL("/icons/" + iconKey + "/icon");
response.sendRedirect(ContextUtils.getRootPath(request) + location);

Check warning

Code scanning / CodeQL

URL redirection from remote source Medium

Untrusted URL redirection depends on a
user-provided value
.
}

@GetMapping(value = "/{key}/icon")
Expand Down
Loading