Skip to content

Commit

Permalink
Merge branch 'master' into ATT-53
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Aug 19, 2024
2 parents cc857ee + 8ea5866 commit 619a734
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>attachments</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>attachments-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion omod/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.openmrs.module</groupId>
<artifactId>attachments</artifactId>
<version>3.2.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
</parent>

<artifactId>attachments-omod</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.openmrs.module.attachments.AttachmentsContext.getContentFamily;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

import javax.servlet.http.HttpServletResponse;

Expand All @@ -23,6 +24,7 @@
import org.openmrs.module.webservices.rest.web.response.ResponseException;
import org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController;
import org.openmrs.obs.ComplexData;
import org.openmrs.web.WebUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand Down Expand Up @@ -69,7 +71,12 @@ public void getFile(@PathVariable("uuid") String uuid, @RequestParam(required =
response.addHeader("File-Ext", getExtension(attComplexData.getTitle(), mimeType));

try {
response.getOutputStream().write(attComplexData.asByteArray());
byte[] bytes = attComplexData.asByteArray();
if (mimeType != null && mimeType.startsWith("text")) {
String byteString = WebUtil.encodeForHtmlContent(new String(bytes, StandardCharsets.UTF_8));
bytes = byteString.getBytes(StandardCharsets.UTF_8);
}
response.getOutputStream().write(bytes);
}
catch (IOException ex) {
response.setStatus(500);
Expand Down
7 changes: 0 additions & 7 deletions omod/src/main/resources/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,6 @@
<!-- Module Activator -->
<activator>${project.parent.groupId}.${project.parent.artifactId}.AttachmentsActivator</activator>


<!-- Adds link to admin page -->
<extension>
<point>org.openmrs.admin.list</point>
<class>${project.parent.groupId}.${project.parent.artifactId}.extension.html.AdminList</class>
</extension>

<!-- Internationalization -->
<!-- All message codes should start with ${project.parent.artifactId}. -->
<messages>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.openmrs.module</groupId>
<artifactId>attachments</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>3.3.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Attachments</name>
<description>
Expand Down

0 comments on commit 619a734

Please sign in to comment.