Properly handle invalid characters in identifiers for Wordpress

This commit is contained in:
Max Dor
2018-04-02 14:36:23 +02:00
parent ac6f549618
commit 91ccb75fa1
2 changed files with 12 additions and 4 deletions

View File

@@ -83,8 +83,12 @@ public class WordpressDirectoryProvider implements IDirectoryProvider {
while (rSet.next()) { while (rSet.next()) {
processRow(rSet).ifPresent(e -> { processRow(rSet).ifPresent(e -> {
e.setUserId(MatrixID.from(e.getUserId(), mxCfg.getDomain()).valid().getId()); try {
result.addResult(e); 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());
}
}); });
} }

View File

@@ -87,10 +87,14 @@ public class WordpressThreePidProvider implements IThreePidProvider {
while (rSet.next()) { while (rSet.next()) {
String uid = rSet.getString("uid"); String uid = rSet.getString("uid");
log.info("Found match: {}", 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(); return Optional.empty();
} }
} catch (SQLException e) { } catch (SQLException e) {