Skip to content

Commit

Permalink
Escape html in user input
Browse files Browse the repository at this point in the history
  • Loading branch information
tdrwenski committed Aug 12, 2024
1 parent 3bd01bf commit 859ef5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions dap4/d4servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies {
implementation 'edu.ucar:httpservices'
implementation 'edu.ucar:cdm-core'

compileOnly 'org.apache.commons:commons-lang3'
compileOnly 'jakarta.servlet:jakarta.servlet-api'
compileOnly 'org.slf4j:slf4j-api'
}
4 changes: 4 additions & 0 deletions dap4/d4servlet/src/main/java/dap4/servlet/DapDSR.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.net.MalformedURLException;
import java.net.URL;

import org.apache.commons.lang3.StringEscapeUtils;

/**
* Generate the DSR for a dataset.
* Currently only generates a minimal DSR.
Expand Down Expand Up @@ -132,6 +134,8 @@ protected String getTemplate(ResponseFormat format) throws IOException {
}

protected void substitute(StringBuilder buf, String macro, String value) {
value = StringEscapeUtils.escapeHtml4(value);

int from = 0;
String tag = "${" + macro + "}";
int taglen = tag.length();
Expand Down

0 comments on commit 859ef5e

Please sign in to comment.