Skip to content

Commit 6271940

Browse files
snomiaoclaude
andcommitted
fix: address PR review comments
- Fix Spanish translations in locales/es/common.json (lines 155, 259) - Fix French translation in locales/fr/common.json (line 154) - Replace 'any' type with React.ComponentProps in AdminCreateNodeFormModal.stories.tsx - Add base64 validation before atob() in AdminCreateNodeFormModal.tsx - Replace regex TOML parsing with proper smol-toml library for robust parsing - Fix prefer-template ESLint warning 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 19d5663 commit 6271940

File tree

6 files changed

+62
-35
lines changed

6 files changed

+62
-35
lines changed

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"react-use-cookie": "^1.6.1",
7070
"sflow": "^1.24.5",
7171
"sharp": "^0.34.3",
72+
"smol-toml": "^1.4.2",
7273
"styled-jsx": "^5.1.7",
7374
"yaml": "^2.8.1",
7475
"zod": "^3.25.76",
@@ -2526,6 +2527,8 @@
25262527

25272528
"slice-ansi": ["[email protected]", "", { "dependencies": { "ansi-styles": "^6.2.1", "is-fullwidth-code-point": "^5.0.0" } }, "sha512-iOBWFgUX7caIZiuutICxVgX1SdxwAVFFKwt1EvMYYec/NWO5meOJ6K5uQxhrYBdQJne4KxiqZc+KptFOWFSI9w=="],
25282529

2530+
"smol-toml": ["[email protected]", "", {}, "sha512-rInDH6lCNiEyn3+hH8KVGFdbjc099j47+OSgbMrfDYX1CmXLfdKd7qi6IfcWj2wFxvSVkuI46M+wPGYfEOEj6g=="],
2531+
25292532
"source-map": ["[email protected]", "", {}, "sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ=="],
25302533

25312534
"source-map-js": ["[email protected]", "", {}, "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="],

components/nodes/AdminCreateNodeFormModal.tsx

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { useState } from 'react'
77
import { useForm } from 'react-hook-form'
88
import { HiDownload, HiPlus } from 'react-icons/hi'
99
import { toast } from 'react-toastify'
10+
import TOML from 'smol-toml'
1011
import { customThemeTModal } from 'utils/comfyTheme'
1112
import { z } from 'zod'
1213
import {
@@ -79,45 +80,65 @@ async function fetchGitHubRepoInfo(
7980
}
8081

8182
const data = await response.json()
83+
// Validate encoding and base64 content
84+
if (data.encoding !== 'base64') {
85+
throw new Error(
86+
`Unexpected encoding for pyproject.toml: ${data.encoding}`
87+
)
88+
}
89+
// Basic base64 validation regex (allows padding)
90+
const base64Regex =
91+
/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/
92+
if (!base64Regex.test(data.content)) {
93+
throw new Error('Invalid base64 content in pyproject.toml')
94+
}
8295
const content = atob(data.content)
8396

84-
// Basic TOML parsing for pyproject.toml
85-
const projectSection =
86-
content.match(/\[project\]([\s\S]*?)(?=\n\[|\n$|$)/)?.[1] || ''
97+
// Parse TOML using proper TOML library
98+
const parsed = TOML.parse(content)
8799

88100
const result: PyProjectData = {}
89101

90-
// Extract name
91-
const nameMatch = projectSection.match(/name\s*=\s*["']([^"']+)["']/)
92-
if (nameMatch) result.name = nameMatch[1]
102+
// Extract project metadata
103+
if (parsed.project && typeof parsed.project === 'object') {
104+
const project = parsed.project as any
93105

94-
// Extract description
95-
const descMatch = projectSection.match(
96-
/description\s*=\s*["']([^"']+)["']/
97-
)
98-
if (descMatch) result.description = descMatch[1]
106+
// Extract name
107+
if (typeof project.name === 'string') {
108+
result.name = project.name
109+
}
99110

100-
// Extract author (from authors array or single author field)
101-
const authorsMatch = projectSection.match(
102-
/authors\s*=\s*\[([\s\S]*?)\]/
103-
)
104-
if (authorsMatch) {
105-
const authorNameMatch = authorsMatch[1].match(
106-
/name\s*=\s*["']([^"']+)["']/
107-
)
108-
if (authorNameMatch) result.author = authorNameMatch[1]
109-
} else {
110-
const authorMatch = projectSection.match(
111-
/author\s*=\s*["']([^"']+)["']/
112-
)
113-
if (authorMatch) result.author = authorMatch[1]
114-
}
111+
// Extract description
112+
if (typeof project.description === 'string') {
113+
result.description = project.description
114+
}
115+
116+
// Extract author (from authors array or single author field)
117+
if (Array.isArray(project.authors) && project.authors.length > 0) {
118+
const firstAuthor = project.authors[0]
119+
if (
120+
typeof firstAuthor === 'object' &&
121+
typeof firstAuthor.name === 'string'
122+
) {
123+
result.author = firstAuthor.name
124+
}
125+
} else if (typeof project.author === 'string') {
126+
result.author = project.author
127+
}
115128

116-
// Extract license
117-
const licenseMatch =
118-
projectSection.match(/license\s*=\s*["']([^"']+)["']/) ||
119-
content.match(/license\s*=\s*\{\s*text\s*=\s*["']([^"']+)["']/)
120-
if (licenseMatch) result.license = licenseMatch[1]
129+
// Extract license
130+
if (typeof project.license === 'string') {
131+
result.license = project.license
132+
} else if (
133+
typeof project.license === 'object' &&
134+
project.license !== null
135+
) {
136+
const license = project.license as any
137+
if (typeof license.text === 'string') {
138+
result.license = license.text
139+
}
140+
}
141+
}
121142

122143
return result
123144
} catch (error) {

locales/es/common.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"Failed to delete node. {{message}}": "No se pudo eliminar el nodo. {{message}}",
153153
"Failed to delete version": "Error al eliminar la versión",
154154
"Failed to delete version: {{message}}": "无法删除版本:{{message}}",
155-
"Failed to fetch repository information: {{error}}": "无法获取仓库信息:{{error}}",
155+
"Failed to fetch repository information: {{error}}": "No se pudo obtener la información del repositorio: {{error}}",
156156
"Failed to get GitHub user information. Please try again.": "No se pudo obtener la información del usuario de GitHub. Por favor, inténtelo de nuevo.",
157157
"Failed to update node": "Error al actualizar el nodo",
158158
"Failed to update node version": "Actualización de versión de nodo fallida",
@@ -256,7 +256,7 @@
256256
"Path To License File": "Ruta al Archivo de Licencia",
257257
"Pending": "Pendiente",
258258
"Pending Security Review": "Revisión de Seguridad Pendiente",
259-
"Please enter a repository URL first": "请先输入仓库 URL",
259+
"Please enter a repository URL first": "Por favor, ingrese primero una URL de repositorio",
260260
"Please provide a reason": "Por favor proporciona una razón",
261261
"Please save this secret key somewhere safe and accessible. If you lose this secret key, you'll need to generate a new one. It can only be copied once.": "Por favor, guarde esta clave secreta en un lugar seguro y accesible. Si pierde esta clave secreta, necesitará generar una nueva. Solo se puede copiar una vez.",
262262
"Please select a publisher": "Por favor seleccione un editor",

locales/fr/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
"Failed to delete node": "Échec de la suppression du nœud",
152152
"Failed to delete node. {{message}}": "Échec de la suppression du nœud. {{message}}",
153153
"Failed to delete version": "Échec de la suppression de la version",
154-
"Failed to delete version: {{message}}": "无法删除版本:{{message}}",
154+
"Failed to delete version: {{message}}": "Échec de la suppression de la version : {{message}}",
155155
"Failed to fetch repository information: {{error}}": "Échec de la récupération des informations du dépôt : {{error}}",
156156
"Failed to get GitHub user information. Please try again.": "Impossible d'obtenir les informations de l'utilisateur GitHub. Veuillez réessayer.",
157157
"Failed to update node": "Échec de la mise à jour du nœud",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
"react-use-cookie": "^1.6.1",
9595
"sflow": "^1.24.5",
9696
"sharp": "^0.34.3",
97+
"smol-toml": "^1.4.2",
9798
"styled-jsx": "^5.1.7",
9899
"yaml": "^2.8.1",
99100
"zod": "^3.25.76"

src/stories/components/nodes/AdminCreateNodeFormModal.stories.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export default meta
5050
type Story = StoryObj<typeof meta>
5151

5252
// Story wrapper component to handle modal state
53-
function ModalWrapper(args: any) {
53+
function ModalWrapper(
54+
args: React.ComponentProps<typeof AdminCreateNodeFormModal>
55+
) {
5456
const [open, setOpen] = useState(true)
5557

5658
return (

0 commit comments

Comments
 (0)