mirror of
				https://github.com/TeamPiped/Piped-Backend.git
				synced 2024-08-14 23:51:41 +00:00 
			
		
		
		
	Merge pull request #503 from TeamPiped/fix-feeds-encoding
Fix escaping URL content that contains special characters.
This commit is contained in:
		
						commit
						3cae269adb
					
				
					 1 changed files with 10 additions and 10 deletions
				
			
		| 
						 | 
				
			
			@ -1,19 +1,14 @@
 | 
			
		|||
package me.kavin.piped.utils;
 | 
			
		||||
 | 
			
		||||
import com.rometools.rome.feed.synd.*;
 | 
			
		||||
import me.kavin.piped.consts.Constants;
 | 
			
		||||
import me.kavin.piped.utils.obj.db.Channel;
 | 
			
		||||
import me.kavin.piped.utils.obj.db.Video;
 | 
			
		||||
import okhttp3.Request;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.apache.commons.text.StringEscapeUtils;
 | 
			
		||||
import org.hibernate.StatelessSession;
 | 
			
		||||
 | 
			
		||||
import com.rometools.rome.feed.synd.SyndContent;
 | 
			
		||||
import com.rometools.rome.feed.synd.SyndContentImpl;
 | 
			
		||||
import com.rometools.rome.feed.synd.SyndEntry;
 | 
			
		||||
import com.rometools.rome.feed.synd.SyndEntryImpl;
 | 
			
		||||
import com.rometools.rome.feed.synd.SyndPerson;
 | 
			
		||||
import com.rometools.rome.feed.synd.SyndPersonImpl;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.net.MalformedURLException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
| 
						 | 
				
			
			@ -75,7 +70,7 @@ public class ChannelHelpers {
 | 
			
		|||
        SyndPerson person = new SyndPersonImpl();
 | 
			
		||||
        SyndContent content = new SyndContentImpl();
 | 
			
		||||
        SyndContent thumbnail = new SyndContentImpl();
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        person.setName(channel.getUploader());
 | 
			
		||||
        person.setUri(Constants.FRONTEND_URL + "/channel/" + channel.getUploaderId());
 | 
			
		||||
        entry.setAuthors(Collections.singletonList(person));
 | 
			
		||||
| 
						 | 
				
			
			@ -87,12 +82,17 @@ public class ChannelHelpers {
 | 
			
		|||
        String contentText = String.format("Title: %s\nViews: %d\nId: %s\nDuration: %d\nIs YT Shorts: %b", video.getTitle(), video.getViews(), video.getId(), video.getDuration(), video.isShort());
 | 
			
		||||
        content.setValue(contentText);
 | 
			
		||||
 | 
			
		||||
        String thumbnailContent = String.format("<a href=\"%s\"><img src=\"%s\"/></a>", Constants.FRONTEND_URL + "/watch?v=" + video.getId(), video.getThumbnail());
 | 
			
		||||
        String thumbnailContent = StringEscapeUtils.escapeXml11(
 | 
			
		||||
                String.format("<div xmlns=\"http://www.w3.org/1999/xhtml\"><a href=\"%s\"><img src=\"%s\"/></a></div>",
 | 
			
		||||
                        Constants.FRONTEND_URL + "/watch?v=" + video.getId()
 | 
			
		||||
                        , video.getThumbnail()
 | 
			
		||||
                )
 | 
			
		||||
        );
 | 
			
		||||
        thumbnail.setType("xhtml");
 | 
			
		||||
        thumbnail.setValue(thumbnailContent);
 | 
			
		||||
 | 
			
		||||
        entry.setContents(List.of(thumbnail, content));
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return entry;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue