@@ -1519,11 +1519,11 @@ public User addUser(String id, String eid, String firstName, String lastName, St
1519
1519
UserEdit edit = addUser (id , eid );
1520
1520
1521
1521
// fill in the fields
1522
- edit .setLastName (formattedText (). sanitizeUserInput ( lastName ) );
1523
- edit .setFirstName (formattedText (). sanitizeUserInput ( firstName ) );
1524
- edit .setEmail (formattedText (). sanitizeUserInput ( email ) );
1522
+ edit .setLastName (lastName );
1523
+ edit .setFirstName (firstName );
1524
+ edit .setEmail (email );
1525
1525
edit .setPassword (pw );
1526
- edit .setType (formattedText (). sanitizeUserInput ( type ) );
1526
+ edit .setType (type );
1527
1527
1528
1528
ResourcePropertiesEdit props = edit .getPropertiesEdit ();
1529
1529
if (properties != null )
@@ -1769,43 +1769,44 @@ protected void addLiveUpdateProperties(BaseUserEdit edit)
1769
1769
edit .m_lastModifiedInstant = Instant .now ();
1770
1770
}
1771
1771
1772
- /**
1773
- * Adjust the id - trim it to null. Note: eid case insensitive option does NOT apply to id.
1774
- *
1775
- * @param id
1776
- * The id to clean up.
1777
- * @return A cleaned up id.
1778
- */
1779
- protected String cleanId (String id ) {
1780
- if (StringUtils .isEmpty (id )){
1781
- return null ;
1782
- }
1783
- // if we are not doing separate id and eid, use the eid rules
1784
- if (!m_separateIdEid ) {
1785
- id = cleanEid (id );
1786
- }
1787
- id = formattedText ().sanitizeUserInput (id );
1788
- // max length for an id is 99 chars
1772
+ /**
1773
+ * Adjust the id - trim it to null. Note: eid case insensitive option does NOT apply to id.
1774
+ *
1775
+ * @param id
1776
+ * The id to clean up.
1777
+ * @return A cleaned up id.
1778
+ */
1779
+ protected String cleanId (String id )
1780
+ {
1781
+ // if we are not doing separate id and eid, use the eid rules
1782
+ if (!m_separateIdEid ) {
1783
+ id = cleanEid (id );
1784
+ }
1785
+ id = StringUtils .trimToNull (id );
1786
+ // max length for an id is 99 chars
1789
1787
id = StringUtils .abbreviate (id , 99 );
1790
- return id ;
1791
- }
1788
+ return id ;
1789
+ }
1792
1790
1793
- /**
1794
- * Adjust the eid - trim it to null, and lower case IF we are case insensitive.
1795
- *
1796
- * @param eid
1797
- * The eid to clean up.
1798
- * @return A cleaned up eid.
1799
- */
1800
- protected String cleanEid (String eid ) {
1801
- if (StringUtils .isEmpty (eid )){
1802
- return null ;
1803
- }
1791
+ /**
1792
+ * Adjust the eid - trim it to null, and lower case IF we are case insensitive.
1793
+ *
1794
+ * @param eid
1795
+ * The eid to clean up.
1796
+ * @return A cleaned up eid.
1797
+ */
1798
+ protected String cleanEid (String eid )
1799
+ {
1804
1800
eid = StringUtils .lowerCase (eid );
1805
- eid = formattedText ().sanitizeUserInput (eid );
1801
+ eid = StringUtils .trimToNull (eid );
1802
+
1803
+ if (eid != null ) {
1804
+ // remove all instances of these chars <>,;:\"
1805
+ eid = StringUtils .replaceChars (eid , "<>,;:\\ /" , "" );
1806
+ }
1806
1807
// NOTE: length check is handled later on
1807
1808
return eid ;
1808
- }
1809
+ }
1809
1810
1810
1811
protected UserEdit getCachedUser (String ref )
1811
1812
{
@@ -2030,7 +2031,7 @@ public boolean updateUserId(String id,String newEmail)
2030
2031
return false ;
2031
2032
}
2032
2033
user .setEid (newEmail );
2033
- user .setEmail (formattedText (). sanitizeUserInput ( newEmail ) );
2034
+ user .setEmail (newEmail );
2034
2035
((BaseUserEdit ) user ).setEvent (SECURE_UPDATE_USER_ANY );
2035
2036
commitEdit (user );
2036
2037
return true ;
@@ -2174,7 +2175,7 @@ public BaseUserEdit(String id, String eid)
2174
2175
// if the id is not null (a new user, rather than a reconstruction)
2175
2176
// and not the anon (id == "") user,
2176
2177
// add the automatic (live) properties
2177
- if (StringUtils . isNotEmpty (m_id )) addLiveProperties (this );
2178
+ if ((m_id != null ) && ( m_id . length () > 0 )) addLiveProperties (this );
2178
2179
2179
2180
//KNL-567 lazy set the properties to be lazy so they get loaded
2180
2181
props .setLazy (true );
@@ -2214,13 +2215,13 @@ public BaseUserEdit(Element el)
2214
2215
2215
2216
m_id = cleanId (el .getAttribute ("id" ));
2216
2217
m_eid = cleanEid (el .getAttribute ("eid" ));
2217
- m_firstName = formattedText (). sanitizeUserInput (el .getAttribute ("first-name" ));
2218
- m_lastName = formattedText (). sanitizeUserInput (el .getAttribute ("last-name" ));
2219
- setEmail (el .getAttribute ("email" ));
2218
+ m_firstName = StringUtils . trimToNull (el .getAttribute ("first-name" ));
2219
+ m_lastName = StringUtils . trimToNull (el .getAttribute ("last-name" ));
2220
+ setEmail (StringUtils . trimToNull ( el .getAttribute ("email" ) ));
2220
2221
m_pw = el .getAttribute ("pw" );
2221
- m_type = formattedText (). sanitizeUserInput (el .getAttribute ("type" ));
2222
- m_createdUserId = formattedText (). sanitizeUserInput (el .getAttribute ("created-id" ));
2223
- m_lastModifiedUserId = formattedText (). sanitizeUserInput (el .getAttribute ("modified-id" ));
2222
+ m_type = StringUtils . trimToNull (el .getAttribute ("type" ));
2223
+ m_createdUserId = StringUtils . trimToNull (el .getAttribute ("created-id" ));
2224
+ m_lastModifiedUserId = StringUtils . trimToNull (el .getAttribute ("modified-id" ));
2224
2225
2225
2226
String time = StringUtils .trimToNull (el .getAttribute ("created-time" ));
2226
2227
if (time != null )
@@ -2315,15 +2316,15 @@ public BaseUserEdit(Element el)
2315
2316
public BaseUserEdit (String id , String eid , String email , String firstName , String lastName , String type , String pw ,
2316
2317
String createdBy , Instant createdOn , String modifiedBy , Instant modifiedOn )
2317
2318
{
2318
- m_id = cleanId ( id ) ;
2319
- m_eid = cleanEid ( eid ) ;
2320
- m_firstName = formattedText (). sanitizeUserInput ( firstName ) ;
2321
- m_lastName = formattedText (). sanitizeUserInput ( lastName ) ;
2322
- m_type = formattedText (). sanitizeUserInput ( type ) ;
2319
+ m_id = id ;
2320
+ m_eid = eid ;
2321
+ m_firstName = firstName ;
2322
+ m_lastName = lastName ;
2323
+ m_type = type ;
2323
2324
setEmail (email );
2324
2325
m_pw = pw ;
2325
- m_createdUserId = formattedText (). sanitizeUserInput ( createdBy ) ;
2326
- m_lastModifiedUserId = formattedText (). sanitizeUserInput ( modifiedBy ) ;
2326
+ m_createdUserId = createdBy ;
2327
+ m_lastModifiedUserId = modifiedBy ;
2327
2328
if (createdOn != null ) m_createdInstant = createdOn ;
2328
2329
if (modifiedBy != null ) m_lastModifiedInstant = modifiedOn ;
2329
2330
@@ -2628,7 +2629,7 @@ public String getDisplayId() {
2628
2629
*/
2629
2630
public String getFirstName ()
2630
2631
{
2631
- if (StringUtils . isEmpty ( m_firstName )) return StringUtils . EMPTY ;
2632
+ if (m_firstName == null ) return "" ;
2632
2633
return m_firstName ;
2633
2634
}
2634
2635
@@ -2637,7 +2638,7 @@ public String getFirstName()
2637
2638
*/
2638
2639
public String getLastName ()
2639
2640
{
2640
- if (StringUtils . isEmpty ( m_lastName )) return StringUtils . EMPTY ;
2641
+ if (m_lastName == null ) return "" ;
2641
2642
return m_lastName ;
2642
2643
}
2643
2644
@@ -2682,7 +2683,7 @@ public String getSortName()
2682
2683
*/
2683
2684
public String getEmail ()
2684
2685
{
2685
- if (StringUtils . isEmpty ( m_email )) return StringUtils . EMPTY ;
2686
+ if (m_email == null ) return "" ;
2686
2687
return m_email ;
2687
2688
}
2688
2689
@@ -2800,7 +2801,8 @@ public void setEid(String eid)
2800
2801
public void setFirstName (String name )
2801
2802
{
2802
2803
if (!m_restrictedFirstName ) {
2803
- m_firstName = formattedText ().sanitizeUserInput (name );
2804
+ // https://jira.sakaiproject.org/browse/SAK-20226 - removed html from name
2805
+ m_firstName = formattedText ().convertFormattedTextToPlaintext (name );
2804
2806
m_sortName = null ;
2805
2807
}
2806
2808
}
@@ -2811,7 +2813,8 @@ public void setFirstName(String name)
2811
2813
public void setLastName (String name )
2812
2814
{
2813
2815
if (!m_restrictedLastName ) {
2814
- m_lastName = formattedText ().sanitizeUserInput (name );
2816
+ // https://jira.sakaiproject.org/browse/SAK-20226 - removed html from name
2817
+ m_lastName = formattedText ().convertFormattedTextToPlaintext (name );
2815
2818
m_sortName = null ;
2816
2819
}
2817
2820
}
@@ -2822,7 +2825,7 @@ public void setLastName(String name)
2822
2825
public void setEmail (String email )
2823
2826
{
2824
2827
if (!m_restrictedEmail ) {
2825
- m_email = formattedText (). sanitizeUserInput ( email ) ;
2828
+ m_email = email ;
2826
2829
}
2827
2830
}
2828
2831
@@ -2857,7 +2860,7 @@ public void setType(String type)
2857
2860
{
2858
2861
if (!m_restrictedType ) {
2859
2862
2860
- m_type = formattedText (). sanitizeUserInput ( type ) ;
2863
+ m_type = type ;
2861
2864
2862
2865
}
2863
2866
}
0 commit comments