Prevent attribution_link urls to be accepted by channel links handler

This commit is contained in:
Bartosz Rumiński 2020-10-09 19:07:38 +02:00
parent 4e04991762
commit 8c38a5509e
2 changed files with 6 additions and 2 deletions

View File

@ -56,8 +56,9 @@ public class YoutubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
* @param splitPath path segments array
* @return true - if value conform to short channel url, false - not
*/
public boolean isCustomShortChannelUrl(String[] splitPath) {
return splitPath.length == 1 && !splitPath[0].matches("playlist|watch");
private boolean isCustomShortChannelUrl(String[] splitPath) {
return splitPath.length == 1 &&
!splitPath[0].matches("playlist|watch|attribution_link");
}
@Override

View File

@ -8,6 +8,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@ -46,6 +47,8 @@ public class YoutubeChannelLinkHandlerFactoryTest {
assertTrue(linkHandler.acceptUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA"));
assertTrue(linkHandler.acceptUrl("https://invidio.us/channel/UClq42foiSgl7sSpLupnugGA/videos?disable_polymer=1"));
assertFalse(linkHandler.acceptUrl("http://www.youtube.com/attribution_link?a=JdfC0C9V6ZI&u=%2Fwatch%3Fv%3DEhxJLojIE_o%26feature%3Dshare"));
}
@Test