Skip to content

Commit

Permalink
Properly handle invalid characters in identifiers for Wordpress
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Dor committed Apr 2, 2018
1 parent ac6f549 commit 91ccb75
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ public UserDirectorySearchResult search(String searchTerm, String query) {

while (rSet.next()) {
processRow(rSet).ifPresent(e -> {
e.setUserId(MatrixID.from(e.getUserId(), mxCfg.getDomain()).valid().getId());
result.addResult(e);
try {
e.setUserId(MatrixID.from(e.getUserId(), mxCfg.getDomain()).valid().getId());
result.addResult(e);
} catch (IllegalArgumentException ex) {
log.warn("Ignoring result {} - Invalid characters for a Matrix ID", e.getUserId());
}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ protected Optional<_MatrixID> find(ThreePid tpid) {
while (rSet.next()) {
String uid = rSet.getString("uid");
log.info("Found match: {}", uid);
return Optional.of(MatrixID.from(uid, mxCfg.getDomain()).valid());
try {
return Optional.of(MatrixID.from(uid, mxCfg.getDomain()).valid());
} catch (IllegalArgumentException ex) {
log.warn("Ignoring match {} - Invalid characters for a Matrix ID", uid);
}
}

log.info("No match found in Wordpress");
log.info("No valid match found in Wordpress");
return Optional.empty();
}
} catch (SQLException e) {
Expand Down

0 comments on commit 91ccb75

Please sign in to comment.