Skip to content

Commit

Permalink
Use StandardCharsets.ISO_8859_1
Browse files Browse the repository at this point in the history
  • Loading branch information
bencomp committed Oct 31, 2023
1 parent e188ed4 commit 8c23e66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/Shib.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ private String getRequiredValueFromAssertion(String key) throws Exception {
throw new Exception(key + " was empty");
}
if (systemConfig.isShibAttributeCharacterSetConversionEnabled()) {
attributeValue= new String( attributeValue.getBytes("ISO-8859-1"), StandardCharsets.UTF_8);
attributeValue= new String( attributeValue.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
}
String trimmedValue = attributeValue.trim();
logger.fine("The SAML assertion for \"" + key + "\" (required) was \"" + attributeValue + "\" and was trimmed to \"" + trimmedValue + "\".");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ private void decodeHeader(BufferedInputStream stream) throws IOException {
}

String data_label = new String(Arrays.copyOfRange(header, dl_offset,
(dl_offset + dataLabelLength)), "ISO-8859-1");
(dl_offset + dataLabelLength)), StandardCharsets.ISO_8859_1);

if (dbgLog.isLoggable(Level.FINE)) {
dbgLog.fine("data_label_length=" + data_label.length());
Expand All @@ -711,7 +711,7 @@ private void decodeHeader(BufferedInputStream stream) throws IOException {
if (releaseNumber > 104) {
int ts_offset = dl_offset + dataLabelLength;
String time_stamp = new String(Arrays.copyOfRange(header, ts_offset,
ts_offset + TIME_STAMP_LENGTH), "ISO-8859-1");
ts_offset + TIME_STAMP_LENGTH), StandardCharsets.ISO_8859_1);
if (dbgLog.isLoggable(Level.FINE)) {
dbgLog.fine("time_stamp_length=" + time_stamp.length());
}
Expand Down Expand Up @@ -913,7 +913,7 @@ private void decodeDescriptorVarNameList(BufferedInputStream stream, int nvar) t
for (DataVariable dataVariable: dataTable.getDataVariables()) {
offset_end += length_var_name;
String vari = new String(Arrays.copyOfRange(variableNameBytes, offset_start,
offset_end), "ISO-8859-1");
offset_end), StandardCharsets.ISO_8859_1);
String varName = getNullStrippedString(vari);
dataVariable.setName(varName);
dbgLog.fine("next name=[" + varName + "]");
Expand Down Expand Up @@ -979,7 +979,7 @@ private void decodeDescriptorVariableFormat(BufferedInputStream stream, int nvar
for (int i = 0; i < nvar; i++) {
offset_end += length_var_format;
String vari = new String(Arrays.copyOfRange(variableFormatList, offset_start,
offset_end), "ISO-8859-1");
offset_end), StandardCharsets.ISO_8859_1);
String variableFormat = getNullStrippedString(vari);
if (dbgLog.isLoggable(Level.FINE)) dbgLog.fine(i + "-th format=[" + variableFormat + "]");

Expand Down Expand Up @@ -1046,7 +1046,7 @@ private void decodeDescriptorValueLabel(BufferedInputStream stream, int nvar) th
for (int i = 0; i < nvar; i++) {
offset_end += length_label_name;
String vari = new String(Arrays.copyOfRange(labelNameList, offset_start,
offset_end), "ISO-8859-1");
offset_end), StandardCharsets.ISO_8859_1);
labelNames[i] = getNullStrippedString(vari);
dbgLog.fine(i + "-th label=[" + labelNames[i] + "]");
offset_start = offset_end;
Expand Down Expand Up @@ -1091,7 +1091,7 @@ private void decodeVariableLabels(BufferedInputStream stream) throws IOException
for (int i = 0; i < nvar; i++) {
offset_end += length_var_label;
String vari = new String(Arrays.copyOfRange(variableLabelBytes, offset_start,
offset_end), "ISO-8859-1");
offset_end), StandardCharsets.ISO_8859_1);

String variableLabelParsed = getNullStrippedString(vari);
if (dbgLog.isLoggable(Level.FINE)) {
Expand Down Expand Up @@ -1273,7 +1273,7 @@ void parseValueLabelsRelease105(BufferedInputStream stream) throws IOException {
valueLabelHeader,
value_label_table_length,
(value_label_table_length + length_label_name)),
"ISO-8859-1");
StandardCharsets.ISO_8859_1);

if (dbgLog.isLoggable(Level.FINE)) {
dbgLog.fine("rawLabelName(length)=" + rawLabelName.length());
Expand Down Expand Up @@ -1336,7 +1336,7 @@ void parseValueLabelsRelease105(BufferedInputStream stream) throws IOException {
for (int l = 0; l < no_value_label_pairs; l++) {

String string_l = new String(Arrays.copyOfRange(valueLabelTable_i, offset_start,
offset_end), "ISO-8859-1");
offset_end), StandardCharsets.ISO_8859_1);

int null_position = string_l.indexOf(0);
if (null_position != -1) {
Expand Down Expand Up @@ -1486,7 +1486,7 @@ private void parseValueLabelsReleasel108(BufferedInputStream stream) throws IOEx
valueLabelHeader,
value_label_table_length,
(value_label_table_length + length_label_name)),
"ISO-8859-1");
StandardCharsets.ISO_8859_1);
String labelName = getNullStrippedString(rawLabelName);

if (dbgLog.isLoggable(Level.FINE)) {
Expand Down Expand Up @@ -1582,7 +1582,7 @@ private void parseValueLabelsReleasel108(BufferedInputStream stream) throws IOEx
String label_segment = new String(
Arrays.copyOfRange(valueLabelTable_i,
offset_value,
(length_label_segment + offset_value)), "ISO-8859-1");
(length_label_segment + offset_value)), StandardCharsets.ISO_8859_1);

// L.A. -- 2011.2.25:
// This assumes that the labels are already stored in the right
Expand Down Expand Up @@ -1928,7 +1928,7 @@ private void decodeData(BufferedInputStream stream) throws IOException {
// String case
int strVarLength = StringLengthTable.get(columnCounter);
String raw_datum = new String(Arrays.copyOfRange(dataRowBytes, byte_offset,
(byte_offset + strVarLength)), "ISO-8859-1");
(byte_offset + strVarLength)), StandardCharsets.ISO_8859_1);
// TODO:
// is it the right thing to do, to default to "ISO-8859-1"?
// (it may be; since there's no mechanism for specifying
Expand Down

0 comments on commit 8c23e66

Please sign in to comment.