jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/394474 )

Change subject: Fix: encode all slashes in page titles
......................................................................


Fix: encode all slashes in page titles

When issuing requests to RESTBase, encode all slashes in page titles
instead of just the first slash.

Change-Id: I6467f11b8bee8778a97c1569565fef652c3d1c81
---
M src/common/http/restbase-path-encoder.test.ts
M src/common/http/restbase-path-encoder.ts
2 files changed, 5 insertions(+), 1 deletion(-)

Approvals:
  Jhernandez: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/common/http/restbase-path-encoder.test.ts 
b/src/common/http/restbase-path-encoder.test.ts
index e40a0f9..6cbaae6 100644
--- a/src/common/http/restbase-path-encoder.test.ts
+++ b/src/common/http/restbase-path-encoder.test.ts
@@ -10,5 +10,9 @@
     it("doesn't reencode already encoded slashes", () => {
       assert.deepStrictEqual(reencodePathSegment("%2f"), "%2f");
     });
+
+    it("all slashes are encoded", () => {
+      assert.deepStrictEqual(reencodePathSegment("//"), "%2f%2f");
+    });
   });
 });
diff --git a/src/common/http/restbase-path-encoder.ts 
b/src/common/http/restbase-path-encoder.ts
index d56014b..aab981b 100644
--- a/src/common/http/restbase-path-encoder.ts
+++ b/src/common/http/restbase-path-encoder.ts
@@ -25,5 +25,5 @@
   // - https://en.wikipedia.org/wiki/?
   // - https://en.wikipedia.org/api/rest_v1/page/mobile-sections//
   // - https://en.wikipedia.org/api/rest_v1/page/mobile-sections/?
-  return segment.replace("/", "%2f");
+  return segment.replace(/\//g, "%2f");
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/394474
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I6467f11b8bee8778a97c1569565fef652c3d1c81
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to