From 51cba5a2879edc3a03678b27fdedd46d51b52386 Mon Sep 17 00:00:00 2001 From: Stypox Date: Wed, 26 Apr 2023 18:36:25 +0200 Subject: [PATCH 1/2] Make sure CI is not vulnerable to bash word splitting See https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ef621c07..90e2b81c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,7 +35,7 @@ jobs: # See gradle file for difference between downloaders - name: Build and run Tests run: | - if [[ $GITHUB_EVENT_NAME == 'schedule' ]]; then + if [[ "$GITHUB_EVENT_NAME" == 'schedule' ]]; then echo running with real downloader ./gradlew check --stacktrace -Ddownloader=REAL else From 945165a3c046fca826a77e1280d5ea2f89a2dae6 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Sun, 30 Apr 2023 17:39:46 +0200 Subject: [PATCH 2/2] [PeerTube] Don't return "No description" when there is no description for a channel or an account When a description is missing, no description should be returned, even the ones indicating there is no description. This behavior is represented by a null return instead. Also update PeertubeAccountExtractorTest to reflect these changes. --- .../peertube/extractors/PeertubeAccountExtractor.java | 8 +++----- .../peertube/extractors/PeertubeChannelExtractor.java | 8 +++----- .../peertube/PeertubeAccountExtractorTest.java | 11 ++++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java index f63eca52f..6a8c2dcf2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java @@ -21,6 +21,7 @@ import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.Utils; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.IOException; import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY; @@ -90,13 +91,10 @@ public class PeertubeAccountExtractor extends ChannelExtractor { return subscribersCount; } + @Nullable @Override public String getDescription() { - try { - return JsonUtils.getString(json, "description"); - } catch (final ParsingException e) { - return "No description"; - } + return json.getString("description"); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java index c5b7bf399..f2a7b07e2 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java @@ -19,6 +19,7 @@ import org.schabi.newpipe.extractor.utils.JsonUtils; import org.schabi.newpipe.extractor.utils.Utils; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.io.IOException; import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY; @@ -63,13 +64,10 @@ public class PeertubeChannelExtractor extends ChannelExtractor { return json.getLong("followersCount"); } + @Nullable @Override public String getDescription() { - try { - return JsonUtils.getString(json, "description"); - } catch (final ParsingException e) { - return "No description"; - } + return json.getString("description"); } @Override diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java index 4e4d14218..ec5bac31d 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/peertube/PeertubeAccountExtractorTest.java @@ -10,10 +10,15 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccountExtractor; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; import static org.schabi.newpipe.extractor.ServiceList.PeerTube; -import static org.schabi.newpipe.extractor.services.DefaultTests.*; +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestGetPageInNewExtractor; +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestMoreItems; +import static org.schabi.newpipe.extractor.services.DefaultTests.defaultTestRelatedItems; /** * Test for {@link PeertubeAccountExtractor} @@ -82,7 +87,7 @@ public class PeertubeAccountExtractorTest { @Test public void testDescription() throws ParsingException { - assertNotNull(extractor.getDescription()); + assertNull(extractor.getDescription()); } @Test