The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
feat: support importing Google lists from a configured data URL base
Luffy937366708496
diff --git a/charts/trek/templates/configmap.yaml b/charts/trek/templates/configmap.yamlindex 5e249f8a1..fa61189c5 100644--- a/charts/trek/templates/configmap.yaml+++ b/charts/trek/templates/configmap.yaml@@ -112,6 +112,9 @@ data:{{- if .Values.env.TREK_PLACES_URL }}TREK_PLACES_URL: {{ .Values.env.TREK_PLACES_URL | quote }}{{- end }}+ {{- if .Values.env.GOOGLE_LIST_DATA_BASE }}+ GOOGLE_LIST_DATA_BASE: {{ .Values.env.GOOGLE_LIST_DATA_BASE | quote }}+ {{- end }}{{- if .Values.env.AMAP_API_BASE }}AMAP_API_BASE: {{ .Values.env.AMAP_API_BASE | quote }}{{- end }}diff --git a/charts/trek/values.yaml b/charts/trek/values.yamlindex 473cb8153..3d05420f3 100644--- a/charts/trek/values.yaml+++ b/charts/trek/values.yaml@@ -108,6 +108,7 @@ env:# nothing there. There is no switch in the admin panel on purpose: whether searches leave the instance is decided# here. Defaults to on.# TREK_PLACES_URL: ""+ # GOOGLE_LIST_DATA_BASE: ""# Base URL of a copy of the Places API you run yourself; it has to answer the same /v1 API. Read from# configuration rather than typed by a user, so an in-cluster address works without ALLOW_INTERNAL_NETWORK.# Defaults to https://places.liketrek.com.diff --git a/docker-compose.yml b/docker-compose.ymlindex c9a1c598a..ab879c62a 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -58,6 +58,7 @@ services:# - TREK_PLACES_ENABLED=false # Optional. Place search (suggestions, full search, category buttons, Road trip search, import geocoding, offline downloads, and the OpenStreetMap ways and horse routes Tours reads) asks the TREK Places API at https://places.liketrek.com by default, so the server makes outbound requests to that host. Set false to search the way it did before 4.3.0 (OpenStreetMap, or your Google/Amap key) and send nothing there. No switch in the admin panel on purpose: whether searches leave the instance is decided here. (default: true)# - TREK_PLACES_URL=https://places.liketrek.com # Optional. Base URL of a copy of the Places API you run yourself; it has to answer the same /v1 API. Read from configuration rather than typed by a user, so an address on your LAN or Docker network works without ALLOW_INTERNAL_NETWORK. (default: https://places.liketrek.com)# - PLACES_API_KEY= # Optional. Google Maps API key (Places API (New) enabled) for place search, photos, details and Google transit. Overrides the key set in Admin > Settings > API Keys, whose field then shows this variable read-only.+# - GOOGLE_LIST_DATA_BASE= # Optional. HTTP(S) base URL of a list-data service. Pasted URLs beginning with this base are imported directly; unset keeps the Google flow.# - AMAP_API_KEY= # Optional. Amap (高德地图) Web 服务 key for place search and geocoding inside mainland China. Overrides the key set in Admin > Settings > API Keys. A Web 端 (JS API) key is a different credential and is rejected with INVALID_USER_KEY.# - AMAP_API_SECRET= # Optional. The private secret (数字签名) of that key. Required exactly when the key was created with signing enabled, because such a key rejects every unsigned request. Leave unset otherwise.# - AMAP_API_BASE=https://restapi.amap.com # Optional. Send the Amap calls through an egress proxy, a cache or a gateway that speaks the same API instead of restapi.amap.com directly. (default: https://restapi.amap.com)diff --git a/server/.env.example b/server/.env.exampleindex 417453086..adbec5755 100644--- a/server/.env.example+++ b/server/.env.example@@ -72,6 +72,7 @@ DEMO_MODE=false # Demo mode: resets data hourly# TREK_PLACES_URL=https://places.liketrek.com # Base URL of a copy of the Places API you run yourself; it has to answer the same /v1 API. Read from configuration rather than typed by a user, so an address on your LAN or Docker network works without ALLOW_INTERNAL_NETWORK. (default: https://places.liketrek.com)# PLACES_API_KEY= # Google Maps API key (Places API (New) enabled) for place search, photos, details and Google transit. Overrides the key set in Admin > Settings > API Keys, whose field then shows this variable read-only. The value never reaches the browser.+# GOOGLE_LIST_DATA_BASE= # Optional HTTP(S) base URL of a list-data service, e.g. https://maps.example.com. Paste a URL beginning with this base to fetch and parse it directly. Unset keeps the original Google list import flow.# AMAP_API_KEY= # Amap (高德地图) Web 服务 key for place search and geocoding inside mainland China. Overrides the key set in Admin > Settings > API Keys. A Web 端 (JS API) key is a different credential and is rejected with INVALID_USER_KEY.# AMAP_API_SECRET= # The private secret (数字签名) of that key. Required exactly when the key was created with signing enabled, because such a key rejects every unsigned request. Leave unset otherwise.diff --git a/server/src/app-config/derive.ts b/server/src/app-config/derive.tsindex 922ca5538..f78ab0fb8 100644--- a/server/src/app-config/derive.ts+++ b/server/src/app-config/derive.ts@@ -140,6 +140,7 @@ export function deriveManaged(raw: RawEnv) {export function deriveMaps(raw: RawEnv) {return {placesApiBase: raw.PLACES_API_BASE || undefined,+ googleListDataBase: raw.GOOGLE_LIST_DATA_BASE?.trim() || undefined,/*** Base URL of the TREK Places API. Unset means the public instance; an* operator who runs their own copy of the index points at it here, and onediff --git a/server/src/app-config/env.schema.ts b/server/src/app-config/env.schema.tsindex ffdc7810b..56a5073a8 100644--- a/server/src/app-config/env.schema.ts+++ b/server/src/app-config/env.schema.ts@@ -181,6 +181,7 @@ export const envSchema = z.object({ADMIN_PASSWORD: anyString,TREK_MANAGED: boolStr,PLACES_API_BASE: url,+ GOOGLE_LIST_DATA_BASE: url,TREK_PLACES_URL: url,TREK_PLACES_ENABLED: boolStr,PLACES_API_KEY: anyString,diff --git a/server/src/nest/place-import/providers/google-list.provider.ts b/server/src/nest/place-import/providers/google-list.provider.tsindex cd17bcab8..60550e104 100644--- a/server/src/nest/place-import/providers/google-list.provider.ts+++ b/server/src/nest/place-import/providers/google-list.provider.ts@@ -1,26 +1,39 @@/**- * A shared Google Maps list, read from Google's own list endpoint.+ * A shared Google Maps list, read from Google's list endpoint or a configured+ * data URL pasted by the user.*- * The link is user input, so it is checked by the SSRF guard first and a short- * link is followed hop by hop through it. A short link that lands on a route- * (the Share sheet on a phone produces exactly that) is handed back as a- * directions link for the directions source; everything else must carry a list- * id. The answer is capped before and after it is read, because its size is- * attacker-influenced through the list id. Every refusal is the exact message- * and status the import route has always answered.+ * Ordinary Google links are checked by the SSRF guard, and short links are+ * followed hop by hop through it. A short link that lands on a route is handed+ * to the directions source; other Google list links must carry a list id.+ * A link under the operator-configured data URL base is read directly and+ * parsed in the same way. Responses are capped because the URL is user input.*/+import { readEnv } from '../../../app-config';import { checkSsrf, safeFetchFollow, SsrfBlockedError } from '../../../utils/ssrfGuard';import { isDirectionsUrl } from '../directions-url.helpers';import type { DirectionsRedirect, GoogleListPlace, ListImportError, ListRead } from '../place-import.types';import { Injectable } from '@nestjs/common';-/** Cap on a provider list-import response body — the payload is attacker-influenced via the list id. */+/** Cap on a provider list-import response body — the payload is attacker-influenced via the URL. */export const MAX_LIST_RESPONSE_BYTES = 8 * 1024 * 1024; // 8 MB/** The browser user agent the list endpoints answer. */export const LIST_USER_AGENT ='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';+export function isGoogleListDataUrl(url: string): boolean {+ const base = readEnv().maps.googleListDataBase;+ if (!base || !url.startsWith(base)) return false;+ try {+ const configured = new URL(base);+ return (+ (configured.protocol === 'http:' || configured.protocol === 'https:') && new URL(url).origin === configured.origin+ );+ } catch {+ return false;+ }+}+export function googleMapsHexId(value: unknown): string | null {if (typeof value !== 'string' && typeof value !== 'number') return null;const raw = String(value).trim();@@ -54,16 +67,18 @@ export class GoogleListProvider {async read(url: string): Promise<ListRead<GoogleListPlace> | DirectionsRedirect | ListImportError> {let listId: string | null = null;let resolvedUrl = url;+ const listDataUrl = isGoogleListDataUrl(url) ? url : null;- // SSRF guard: validate user-supplied URL before fetching- const ssrf = await checkSsrf(url);- if (!ssrf.allowed) return { error: 'URL is not allowed', status: 400 };+ // The operator-configured base may be internal HTTP. Other user links+ // retain the SSRF guard.+ if (!listDataUrl) {+ const ssrf = await checkSsrf(url);+ if (!ssrf.allowed) return { error: 'URL is not allowed', status: 400 };+ }// Follow redirects for short URLs (maps.app.goo.gl, goo.gl). Redirects are- // followed manually so every hop is re-checked against the SSRF guard — a- // short link that 302s to an internal IP is blocked even though the initial- // host is public.- if (url.includes('goo.gl') || url.includes('maps.app')) {+ // followed manually so every hop is re-checked against the SSRF guard.+ if (!listDataUrl && (url.includes('goo.gl') || url.includes('maps.app'))) {try {const redirectRes = await safeFetchFollow(url, { signal: AbortSignal.timeout(10000) });resolvedUrl = redirectRes.url;@@ -81,19 +96,21 @@ export class GoogleListProvider {// this shape, and the box says a directions link works.//// Handed on with the resolved URL, so the hop is not made twice.- if (isDirectionsUrl(resolvedUrl)) return { directions: resolvedUrl };+ if (!listDataUrl && isDirectionsUrl(resolvedUrl)) return { directions: resolvedUrl };- // Pattern: /placelists/list/{ID}- const plMatch = resolvedUrl.match(/placelists\/list\/([A-Za-z0-9_-]+)/);- if (plMatch) listId = plMatch[1];+ if (!listDataUrl) {+ // Pattern: /placelists/list/{ID}+ const plMatch = resolvedUrl.match(/placelists\/list\/([A-Za-z0-9_-]+)/);+ if (plMatch) listId = plMatch[1];- // Pattern: !2s{ID} in data URL params- if (!listId) {- const dataMatch = resolvedUrl.match(/!2s([A-Za-z0-9_-]{15,})/);- if (dataMatch) listId = dataMatch[1];+ // Pattern: !2s{ID} in data URL params+ if (!listId) {+ const dataMatch = resolvedUrl.match(/!2s([A-Za-z0-9_-]{15,})/);+ if (dataMatch) listId = dataMatch[1];+ }}- if (!listId) {+ if (!listDataUrl && !listId) {// A single-place share link (…/maps/place/…) carries no list id — point the user at// the place search box instead of a cryptic "could not extract list ID" (#1304).if (resolvedUrl.includes('/maps/place/')) {@@ -106,10 +123,13 @@ export class GoogleListProvider {return { error: 'Could not extract list ID from URL. Please use a shared Google Maps list link.', status: 400 };}- // Fetch list data from Google Maps internal API- const apiUrl = `https://www.google.com/maps/preview/entitylist/getlist?authuser=0&hl=en&gl=us&pb=!1m1!1s${encodeURIComponent(listId)}!2e2!3e2!4i500!16b1`;+ // Fetch list data from the configured source or Google's internal API.+ const apiUrl =+ listDataUrl ??+ `https://www.google.com/maps/preview/entitylist/getlist?authuser=0&hl=en&gl=us&pb=!1m1!1s${encodeURIComponent(listId)}!2e2!3e2!4i500!16b1`;const apiRes = await fetch(apiUrl, {headers: { 'User-Agent': LIST_USER_AGENT },+ ...(listDataUrl ? { redirect: 'error' as const } : {}),signal: AbortSignal.timeout(15000),});@@ -118,7 +138,7 @@ export class GoogleListProvider {}// Cap the declared body before reading it (transit.service precedent): the- // response is attacker-influenced via the list id, and buffering it whole+ // response is attacker-influenced via the URL, and buffering it whole// used to be unbounded.const declared = Number(apiRes.headers?.get('content-length') ?? 0);if (declared > MAX_LIST_RESPONSE_BYTES) {diff --git a/server/src/nest/places/places.controller.ts b/server/src/nest/places/places.controller.tsindex d019ec160..7872314a2 100644--- a/server/src/nest/places/places.controller.ts+++ b/server/src/nest/places/places.controller.ts@@ -8,6 +8,7 @@ import { isDemoWriteBlocked, DEMO_WRITE_ERROR } from '../common/demo-write';import { PLACE_IMAGE_FILE_FILTER } from '../common/place-image-upload';import { RequirePermission, TripAccessGuard } from '../permissions/trip-access.guard';import { isDirectionsUrl } from '../place-import/place-import.service';+import { isGoogleListDataUrl } from '../place-import/providers/google-list.provider';import { StorageService } from '../storage/storage.service';import { placeImageUrl } from './place-image';import {@@ -320,7 +321,7 @@ export class PlacesController {const result =provider !== 'google'? await this.places.importNaverList(tripId, url, opts)- : isDirectionsUrl(url)+ : isDirectionsUrl(url) && !isGoogleListDataUrl(url)? await this.places.importGoogleDirections(tripId, url, opts): await this.places.importGoogleList(tripId, url, opts);for (const place of result.places) {diff --git a/server/tests/unit/app-config/config-templates.test.ts b/server/tests/unit/app-config/config-templates.test.tsindex bed2d6d70..f47e91cb3 100644--- a/server/tests/unit/app-config/config-templates.test.ts+++ b/server/tests/unit/app-config/config-templates.test.ts@@ -41,6 +41,7 @@ describe('the Places and Amap switches in the templates', () => {const documented = ['TREK_PLACES_ENABLED','TREK_PLACES_URL',+ 'GOOGLE_LIST_DATA_BASE','PLACES_API_KEY','AMAP_API_KEY','AMAP_API_SECRET',@@ -60,7 +61,7 @@ describe('the Places and Amap switches in the templates', () => {});it('the Helm ConfigMap passes through the non-secret ones the values file documents', () => {- for (const name of ['TREK_PLACES_ENABLED', 'TREK_PLACES_URL', 'AMAP_API_BASE']) {+ for (const name of ['TREK_PLACES_ENABLED', 'TREK_PLACES_URL', 'GOOGLE_LIST_DATA_BASE', 'AMAP_API_BASE']) {expect(helmValues).toContain(`# ${name}:`);expect(helmConfigMap).toContain(`${name}: {{ .Values.env.${name} | quote }}`);}diff --git a/server/tests/unit/nest/place-import/google-list.provider.test.ts b/server/tests/unit/nest/place-import/google-list.provider.test.tsindex 23f165d8c..c173cfe26 100644--- a/server/tests/unit/nest/place-import/google-list.provider.test.ts+++ b/server/tests/unit/nest/place-import/google-list.provider.test.ts@@ -7,6 +7,7 @@ import {GoogleListProvider,googleMapsFeatureIdFromItem,googleMapsHexId,+ isGoogleListDataUrl,} from '../../../../src/nest/place-import/providers/google-list.provider';import { SsrfBlockedError } from '../../../../src/utils/ssrfGuard';@@ -24,6 +25,7 @@ vi.mock('../../../../src/utils/ssrfGuard', () => ({afterEach(() => {vi.unstubAllGlobals();+ vi.unstubAllEnvs();mockCheckSsrf.mockReset();mockCheckSsrf.mockResolvedValue({ allowed: true });mockFollow.mockReset();@@ -58,6 +60,77 @@ describe('googleMapsHexId / googleMapsFeatureIdFromItem', () => {});describe('GoogleListProvider.read', () => {+ it('fetches list data from a URL beginning with the configured base', async () => {+ const url = 'http://list-source.example.test/maps/dir/fixture?other=2';+ vi.stubEnv('GOOGLE_LIST_DATA_BASE', 'http://list-source.example.test');+ const body = `)]}'\n${JSON.stringify([+ [+ null,+ null,+ null,+ null,+ 'Fixture list',+ null,+ null,+ null,+ [[null, [null, null, null, null, null, [null, null, 12.34, 56.78]], 'Sample place', '']],+ ],+ ])}`;+ const fetchMock = vi.fn(async (_url: string, _init: RequestInit) => new Response(body));+ vi.stubGlobal('fetch', fetchMock);++ expect(isGoogleListDataUrl(url)).toBe(true);+ expect(await new GoogleListProvider().read(url)).toEqual({+ listName: 'Fixture list',+ places: [{ name: 'Sample place', lat: 12.34, lng: 56.78, notes: null, googleFtid: null }],+ });+ expect(fetchMock).toHaveBeenCalledWith(url, expect.objectContaining({ redirect: 'error' }));+ expect(mockCheckSsrf).not.toHaveBeenCalled();+ expect(mockFollow).not.toHaveBeenCalled();+ });++ it('matches the literal base prefix but rejects lookalike origins', () => {+ const url = 'http://list-source.example.test/fixture';+ vi.stubEnv('GOOGLE_LIST_DATA_BASE', '');+ expect(isGoogleListDataUrl(url)).toBe(false);+ vi.stubEnv('GOOGLE_LIST_DATA_BASE', 'http://list-source.example.test');+ expect(isGoogleListDataUrl(url)).toBe(true);+ expect(isGoogleListDataUrl('http://list-source.example.test/other?id=another')).toBe(true);+ expect(isGoogleListDataUrl('https://list-source.example.test/other')).toBe(false);+ expect(isGoogleListDataUrl('http://list-source.example.test:8787/fixture')).toBe(false);+ expect(isGoogleListDataUrl('http://list-source.example.test.evil.test/fixture')).toBe(false);+ expect(isGoogleListDataUrl('http://[email protected]/fixture')).toBe(false);+ vi.stubEnv('GOOGLE_LIST_DATA_BASE', 'http://list-source.example.test/list');+ expect(isGoogleListDataUrl('http://list-source.example.test/list?id=fixture')).toBe(true);+ expect(isGoogleListDataUrl('http://list-source.example.test/other?id=fixture')).toBe(false);+ });++ it('keeps the original Google-link flow when the base does not match', async () => {+ vi.stubEnv('GOOGLE_LIST_DATA_BASE', 'http://other.example.test');+ const url = 'http://list-source.example.test/fixture';+ const fetchMock = vi.fn();+ vi.stubGlobal('fetch', fetchMock);+ expect(await new GoogleListProvider().read(url)).toEqual({+ error: 'Could not extract list ID from URL. Please use a shared Google Maps list link.',+ status: 400,+ });+ expect(mockCheckSsrf).toHaveBeenCalledWith(url);+ expect(fetchMock).not.toHaveBeenCalled();+ });++ it('reports an invalid configured response without falling back to Google', async () => {+ const url = 'http://list-source.example.test/data';+ vi.stubEnv('GOOGLE_LIST_DATA_BASE', 'http://list-source.example.test');+ const fetchMock = vi.fn(async (_url: string) => new Response('not list data'));+ vi.stubGlobal('fetch', fetchMock);+ expect(await new GoogleListProvider().read(url)).toEqual({+ error: 'Invalid list data received from Google Maps',+ status: 400,+ });+ expect(fetchMock).toHaveBeenCalledTimes(1);+ expect(fetchMock.mock.calls[0][0]).toBe(url);+ });+it('refuses a URL the SSRF guard blocks, before fetching anything', async () => {mockCheckSsrf.mockResolvedValueOnce({ allowed: false });const fetchMock = vi.fn();diff --git a/wiki/Environment-Variables.md b/wiki/Environment-Variables.mdindex c0cc02619..2dd1d4891 100644--- a/wiki/Environment-Variables.md+++ b/wiki/Environment-Variables.md@@ -500,6 +500,7 @@ next key rotation or admin reset would quietly switch the file back to WAL.| `OVERPASS_TIMEOUT_MS` | Per-endpoint timeout (in milliseconds) for Overpass POI requests. Endpoints race in parallel and one that hasn't answered within this window is abandoned so a faster mirror can win. The query itself gives Overpass 20 seconds of work, so a lower value hangs up on answers that were still coming; that is why the default rose from `12000` in 4.3.0. Drop any lower value you set by hand, and raise it only for a slow self-hosted Overpass instance. The Tours search along a tour does not read it: it gives Overpass 10 seconds of work and waits 12, because someone is waiting for the list. Invalid values abort startup. | `25000` || `LLM_TIMEOUT_MS` | How long (in milliseconds) one AI-parsing call may take before it is abandoned. One ceiling for every provider, applied to the abort signal and to the underlying HTTP client alike. The default is generous so heavier parsing work fits without a code change; lower it if you use a cloud provider and would rather fail fast. Invalid values abort startup. | `900000` (15 min) || `LLM_MAX_OUTPUT_TOKENS` | The longest answer (in tokens) one AI-parsing call may ask the model for, sent to every provider. A document with many bookings needs a long answer; when the model hits the cap the import says so and names this variable. Raise it for such documents, but keep prompt plus cap inside the context your model has, or the server refuses the request. Unset keeps each provider's own cap. A whole number from 256 to 1000000, anything else aborts startup. | `4096` (OpenAI-compatible), `8192` (Anthropic) |+| `GOOGLE_LIST_DATA_BASE` | HTTP(S) base URL of a list-data service. A pasted URL starting with this base is fetched and parsed directly; the URL's origin must also match the base so a lookalike host cannot bypass the URL guard. A failed direct import reports an error without falling back to Google. Unset or a nonmatching URL uses the original Google flow. | Unset |> **Routing is not set here.** The routing engines behind the planner and the [Road-Trip](Road-Trip) addon (OSRM for routes, Valhalla for avoiding toll roads, motorways and ferries) have no environment variable. An admin sets them under **Admin → User Defaults** as **Own routing engine** and **Own Valhalla instance**, and they take effect after a restart. `OVERPASS_URL` and `OVERPASS_TIMEOUT_MS` above also apply to the road trip's search along the route.