Fixing URL preview refs #13213

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@176775 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2019-01-24 09:41:44 +00:00
parent 30c8efe0b2
commit 605c9830af
1 changed files with 6 additions and 3 deletions

View File

@ -57,6 +57,7 @@ import org.gcube.portlets.user.shareupdates.shared.UserSettings;
import org.gcube.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.social_networking.socialutillibrary.MessageParser;
import org.gcube.social_networking.socialutillibrary.Utils;
import org.gcube.socialnetworking.token.URLToken;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.RoleManager;
import org.gcube.vomanagement.usermanagement.UserManager;
@ -730,10 +731,12 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
LinkPreview toReturn = null;
_log.info("to check " + linkToCheck);
//look for a url in text
linkToCheck = Utils.extractURL(linkToCheck);
if (linkToCheck == null)
URL url = URLToken.isURL(linkToCheck);
if (url == null) {
return null; //no url
}
linkToCheck = url.toString();
String[] schemes = {"http","https"};
UrlValidator urlValidator = new UrlValidator(schemes);
if (! urlValidator.isValid(linkToCheck)) {