fix: prevent 2-letter folder names from being misidentified as locale codes#7958
Open
syphernl wants to merge 1 commit intorequarks:mainfrom
Open
fix: prevent 2-letter folder names from being misidentified as locale codes#7958syphernl wants to merge 1 commit intorequarks:mainfrom
syphernl wants to merge 1 commit intorequarks:mainfrom
Conversation
… codes getPagePath() used a regex to extract locale prefixes from file paths, but any top-level folder with a 2-letter name (e.g. AI/, CI/) or 2+2-letter hyphenated name (e.g. CI-CD/) matched the BCP 47 locale pattern, causing the extracted non-existent locale to violate the pages_localecode_foreign FK constraint on insert. Now validates the extracted locale against the configured locales (WIKI.config.lang.code + WIKI.config.lang.namespaces) before accepting it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getPagePath()uses a regex to detect locale prefixes in file paths ([a-z]{2}or[a-z]{2}-[a-z]{2})AI/,CI/) or 2+2-letter hyphenated name (CI-CD/) matches the BCP 47 locale patternpages_localecode_foreignFK constraint on insert, failing to sync the page from GitFix: validate the extracted locale candidate against the configured locales (
WIKI.config.lang.code+WIKI.config.lang.namespaces) before accepting it. If not a known locale, the path segment is treated as part of the page path and the default locale is used.Test plan
AI/some-page.md) in the Git repo and trigger a sync — page should import successfullyXX-YYhyphenated folder (e.g.CI-CD/page.md) — samefr/page.mdwhenfris a configured namespace) still resolve correctly