Skip to content

Commit 2422349

Browse files
committed
Merge branch 'develop' into 3776-public-only
2 parents 39ec5e1 + 22090e2 commit 2422349

24 files changed

Lines changed: 775 additions & 118 deletions

doc/sphinx-guides/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
# built documents.
6565
#
6666
# The short X.Y version.
67-
version = '4.7'
67+
version = '4.7.1'
6868
# The full version, including alpha/beta/rc tags.
69-
release = '4.7'
69+
release = '4.7.1'
7070

7171
# The language for content autogenerated by Sphinx. Refer to documentation
7272
# for a list of supported languages.

doc/sphinx-guides/source/index.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
You can adapt this file completely to your liking, but it should at least
44
contain the root `toctree` directive.
55
6-
Dataverse 4.7 Guides
7-
====================
6+
Dataverse 4.7.1 Guides
7+
======================
88

9-
These guides are for the most recent version of Dataverse. For the guides for **version 4.6.2** please go `here <http://guides.dataverse.org/en/4.6.2/>`_.
9+
These guides are for the most recent version of Dataverse. For the guides for **version 4.7** please go `here <http://guides.dataverse.org/en/4.7/>`_.
1010

1111
.. toctree::
1212
:glob:

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>edu.harvard.iq</groupId>
66
<artifactId>dataverse</artifactId>
7-
<version>4.7</version>
7+
<version>4.7.1</version>
88
<packaging>war</packaging>
99

1010
<name>dataverse</name>

scripts/database/upgrades/upgrade_v4.7_to_v4.7.1.sql

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,32 @@
44
ALTER TABLE authenticateduser ADD COLUMN createdtime TIMESTAMP NOT NULL DEFAULT '01-01-2000 00:00:00';
55
ALTER TABLE authenticateduser ADD COLUMN lastlogintime TIMESTAMP DEFAULT NULL;
66
ALTER TABLE authenticateduser ADD COLUMN lastapiusetime TIMESTAMP DEFAULT NULL;
7-
ALTER TABLE authenticateduser DROP COLUMN modificationtime;
7+
ALTER TABLE authenticateduser DROP COLUMN modificationtime;
8+
9+
-- Removing authenticated builtin users who do not exist in the builtin table because they were created through faulty validation
10+
-- creates view containing authentication ids that you will be deleting
11+
CREATE TEMP VIEW useridstodelete AS (SELECT DISTINCT a.id FROM authenticateduserlookup al, authenticateduser a WHERE al.authenticateduser_id = a.id AND al.authenticationproviderid = 'builtin' AND a.useridentifier NOT IN (SELECT username FROM builtinuser));
12+
-- commands to remove the users from the appropriate tables
13+
DELETE FROM confirmemaildata WHERE authenticateduser_id IN (SELECT * FROM useridstodelete);
14+
DELETE FROM usernotification WHERE user_id IN (SELECT * FROM useridstodelete);
15+
DELETE FROM guestbookresponse WHERE authenticateduser_id IN (SELECT * FROM useridstodelete);
16+
DELETE FROM authenticateduserlookup WHERE authenticateduser_id IN (SELECT * FROM useridstodelete);
17+
DELETE FROM authenticateduser WHERE id NOT IN (SELECT authenticateduser_id FROM authenticateduserlookup);
18+
19+
/*
20+
Add validationFormat to DatasetFieldType to
21+
*/
22+
ALTER TABLE datasetfieldtype
23+
ADD COLUMN validationFormat character varying(255);
24+
25+
/*
26+
for testing display format
27+
This adds a display format that links out to an outside site. The format of the #VALUE is
28+
four characters alpha numeric (3fki works)
29+
30+
update datasetfieldtype
31+
set displayformat = '<a target="_blank" href="http://www.rcsb.org/pdb/explore/explore.do?structureId=#VALUE">PDB (RCSB) #VALUE</a>',
32+
fieldType= 'TEXT'
33+
where id = xxx;
34+
35+
*/

src/main/java/Bundle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ user.signup.otherLogInOptions.tip= <a href="/loginpage.xhtml" title="Dataverse L
184184
user.username.illegal.tip=Between 2-60 characters, and can use "a-z", "0-9", "_" for your username.
185185
user.username=Username
186186
user.username.taken=This username is already taken.
187+
user.username.invalid=This username contains an invalid character or is outside the length requirement (2-60 characters).
188+
user.username.valid=Create a valid username of 2 to 60 characters in length containing letters (a-Z), numbers (0-9), dashes (-), underscores (_), and periods (.).
187189
user.noPasswd=No Password
188190
user.currentPasswd=Current Password
189191
user.currentPasswd.tip=Please enter the current password for this account.
@@ -206,7 +208,7 @@ user.acccountterms.iagree=I have read and accept the Dataverse General Terms of
206208
user.createBtn=Create Account
207209
user.updatePassword.welcome=Welcome to Dataverse {0}, {1}
208210
user.updatePassword.warning=With the release of our new Dataverse 4.0 upgrade, the password requirements and General Terms of Use have updated. As this is the first time you are using Dataverse since the update, you need to create a new password and agree to the new General Terms of Use.
209-
user.updatePassword.password=Create a password that is minimum six characters long and uses at least one letter or number.
211+
user.updatePassword.password=Create a password that is minimum six characters long and uses at least one letter and number.
210212
authenticationProvidersAvailable.tip={0}There are no active authentication providers{1}If you are a system administrator, please enable one using the API.{2}If you are not a system administrator, please contact the one for your institution.
211213

212214
#loginpage.xhtml

src/main/java/edu/harvard/iq/dataverse/DatasetField.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public List<String> getValues() {
274274
List returnList = new ArrayList();
275275
if (!datasetFieldValues.isEmpty()) {
276276
for (DatasetFieldValue dsfv : datasetFieldValues) {
277-
returnList.add(dsfv.getValue());
277+
returnList.add(dsfv.getDisplayValue());
278278
}
279279
} else {
280280
for (ControlledVocabularyValue cvv : controlledVocabularyValues) {

src/main/java/edu/harvard/iq/dataverse/DatasetFieldCompoundValue.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
package edu.harvard.iq.dataverse;
77

8+
import edu.harvard.iq.dataverse.util.MarkupChecker;
89
import java.io.Serializable;
910
import java.util.ArrayList;
1011
import java.util.Comparator;
@@ -143,15 +144,18 @@ public Map<DatasetField,String> getDisplayValueMap() {
143144
if (StringUtils.isBlank(format)) {
144145
format = "#VALUE";
145146
}
146-
147+
String sanitizedValue = childDatasetField.getDatasetFieldType().isSanitizeHtml() ? MarkupChecker.sanitizeBasicHTML(childDatasetField.getValue()) : childDatasetField.getValue();
148+
if (!childDatasetField.getDatasetFieldType().isSanitizeHtml() && childDatasetField.getDatasetFieldType().isEscapeOutputText()){
149+
sanitizedValue = MarkupChecker.stripAllTags(sanitizedValue);
150+
}
147151
// replace the special values in the format (note: we replace #VALUE last since we don't
148152
// want any issues if the value itself has #NAME in it)
149153
String displayValue = format
150154
.replace("#NAME", childDatasetField.getDatasetFieldType().getTitle())
151155
//todo: this should be handled in more generic way for any other text that can then be internationalized
152156
// if we need to use replaceAll for regexp, then make sure to use: java.util.regex.Matcher.quoteReplacement(<target string>)
153157
.replace("#EMAIL", ResourceBundle.getBundle("Bundle").getString("dataset.email.hiddenMessage"))
154-
.replace("#VALUE", childDatasetField.getValue());
158+
.replace("#VALUE", sanitizedValue );
155159

156160
fieldMap.put(childDatasetField,displayValue);
157161
}

src/main/java/edu/harvard/iq/dataverse/DatasetFieldType.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ public Long getId() {
4646
public void setId(Long id) {
4747
this.id = id;
4848
}
49-
50-
public String getIdString(){
51-
return id.toString();
52-
}
49+
5350

5451
/**
5552
* The internal, DDI-like name, no spaces, etc.
@@ -83,6 +80,8 @@ public String getIdString(){
8380
* A watermark to be displayed in the UI.
8481
*/
8582
private String watermark;
83+
84+
private String validationFormat;
8685

8786
@OneToMany(mappedBy = "datasetFieldType")
8887
private Set<DataverseFacet> dataverseFacets;
@@ -164,8 +163,23 @@ public void setDisplayFormat(String displayFormat) {
164163
this.displayFormat = displayFormat;
165164
}
166165

166+
public Boolean isSanitizeHtml(){
167+
if (this.fieldType.equals(FieldType.URL)){
168+
return true;
169+
}
170+
return this.fieldType.equals(FieldType.TEXTBOX);
171+
}
172+
173+
public Boolean isEscapeOutputText(){
174+
if (this.fieldType.equals(FieldType.URL)){
175+
return false;
176+
}
177+
if (this.fieldType.equals(FieldType.TEXTBOX)){
178+
return false;
179+
}
180+
return !(this.fieldType.equals(FieldType.TEXT) && this.displayFormat != null &&this.displayFormat.contains("<a"));
181+
}
167182

168-
169183
public String getName() {
170184
return name;
171185
}
@@ -239,6 +253,14 @@ public boolean isFacetable() {
239253
public void setFacetable(boolean facetable) {
240254
this.facetable = facetable;
241255
}
256+
257+
public String getValidationFormat() {
258+
return validationFormat;
259+
}
260+
261+
public void setValidationFormat(String validationFormat) {
262+
this.validationFormat = validationFormat;
263+
}
242264

243265
/**
244266
* Determines whether this field type is displayed in the form when creating

src/main/java/edu/harvard/iq/dataverse/DatasetFieldValidator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ public boolean isValid(DatasetField value, ConstraintValidatorContext context) {
3131
}
3232
if (((dsfType.isPrimitive() && dsfType.isRequired()) || (dsfType.isPrimitive() && value.isRequired()))
3333
&& StringUtils.isBlank(value.getValue())) {
34-
context.buildConstraintViolationWithTemplate(dsfType.getDisplayName() + " is required.").addConstraintViolation();
34+
try{
35+
context.buildConstraintViolationWithTemplate(dsfType.getDisplayName() + " is required.").addConstraintViolation();
36+
} catch (NullPointerException npe){
37+
//if there's no context for the error we can't put it anywhere....
38+
}
39+
3540
return false;
3641
}
3742
return true;

src/main/java/edu/harvard/iq/dataverse/DatasetFieldValue.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
package edu.harvard.iq.dataverse;
88

9+
import edu.harvard.iq.dataverse.util.MarkupChecker;
910
import java.io.Serializable;
1011
import java.util.Comparator;
12+
import java.util.ResourceBundle;
1113
import javax.persistence.Column;
1214
import javax.persistence.Entity;
1315
import javax.persistence.GeneratedValue;
@@ -18,6 +20,7 @@
1820
import javax.persistence.ManyToOne;
1921
import javax.persistence.Table;
2022
import javax.persistence.Transient;
23+
import org.apache.commons.lang.StringUtils;
2124

2225
/**
2326
*
@@ -85,6 +88,31 @@ public String getValueForEdit() {
8588
public void setValueForEdit(String value) {
8689
this.value = value;
8790
}
91+
92+
public String getDisplayValue() {
93+
String retVal = "";
94+
if (!StringUtils.isBlank(this.getValue()) && !DatasetField.NA_VALUE.equals(this.getValue())) {
95+
String format = this.datasetField.getDatasetFieldType().getDisplayFormat();
96+
if (StringUtils.isBlank(format)) {
97+
format = "#VALUE";
98+
}
99+
String sanitizedValue = !this.datasetField.getDatasetFieldType().isSanitizeHtml() ? this.getValue() : MarkupChecker.sanitizeBasicHTML(this.getValue());
100+
101+
if (!this.datasetField.getDatasetFieldType().isSanitizeHtml() && this.datasetField.getDatasetFieldType().isEscapeOutputText()){
102+
sanitizedValue = MarkupChecker.stripAllTags(sanitizedValue);
103+
}
104+
105+
// replace the special values in the format (note: we replace #VALUE last since we don't
106+
// want any issues if the value itself has #NAME in it)
107+
String displayValue = format
108+
.replace("#NAME", this.datasetField.getDatasetFieldType().getTitle() == null ? "" : this.datasetField.getDatasetFieldType().getTitle())
109+
.replace("#EMAIL", ResourceBundle.getBundle("Bundle").getString("dataset.email.hiddenMessage"))
110+
.replace("#VALUE", sanitizedValue);
111+
retVal = displayValue;
112+
}
113+
114+
return retVal;
115+
}
88116

89117
public int getDisplayOrder() {
90118
return displayOrder;

0 commit comments

Comments
 (0)