Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Reject invalid Shopify store labels

Kiran K1aa0ddfad86a
diff --git a/apps/web/lib/integrations/shopify/store-id.ts b/apps/web/lib/integrations/shopify/store-id.ts
index dcd2eee5eb..54bd858972 100644
--- a/apps/web/lib/integrations/shopify/store-id.ts
+++ b/apps/web/lib/integrations/shopify/store-id.ts
@@ -1,4 +1,4 @@
-const SHOPIFY_STORE_ID_REGEX = /^[a-z0-9][a-z0-9-]*\.myshopify\.com$/;
+const SHOPIFY_STORE_ID_REGEX = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.myshopify\.com$/;
// Rejects store IDs that are not a `*.myshopify.com` domain. The store ID is
// used as the Admin API hostname, so anything else could redirect the request.
diff --git a/apps/web/tests/misc/shopify-integration-callback.test.ts b/apps/web/tests/misc/shopify-integration-callback.test.ts
index 9e3c933504..c83ccb0830 100644
--- a/apps/web/tests/misc/shopify-integration-callback.test.ts
+++ b/apps/web/tests/misc/shopify-integration-callback.test.ts
@@ -71,7 +71,13 @@ describe("PATCH /api/shopify/integration/callback", () => {
mocks.updateProject.mockImplementation(async ({ data }) => data);
});
- it.each(["evil.com/x?", "169.254.169.254", "acme.myshopify.com.evil.com"])(
+ it.each([
+ "evil.com/x?",
+ "169.254.169.254",
+ "acme.myshopify.com.evil.com",
+ "acme-.myshopify.com",
+ `${"a".repeat(64)}.myshopify.com`,
+ ])(
"rejects %s without contacting it or saving it",
async (shopifyStoreId) => {
await expect(connect(shopifyStoreId)).rejects.toThrow();