Merge branch 'develop' of https://github.com/gnuboard/dev-g7 into develop

This commit is contained in:
HeuJung committed 2026-08-18 11:04:01 +09:00
commit 07c459f0ff
14 files changed
+481 -34

No files matched your search

+44 -4
View File
@@ -253,6 +253,7 @@ class SeoMetaResolver
return $this->resolveLocalizedValue($value);
}
}
return '';
}
@@ -428,6 +429,37 @@ class SeoMetaResolver
return [$contextIdentifier, $rest];
}
/**
* `<title>` 조립용 접미사를 정규화합니다.
*
* 관리자 저장 경로의 TrimStrings 미들웨어가 접미사의 선행 공백을 제거하므로
* ("` | 그누보드7`" 을 입력해도 "`| 그누보드7`" 로 저장된다), blade 의
* `{{ $title }}{{ $titleSuffix }}` 단순 연결에서 제목과 구분자가 붙어 버린다.
* 이 메서드가 조립 규칙의 SSoT 다:
*
* - 제목이 있고 접미사가 공백으로 시작하지 않으면 공백 하나를 복원해 잇는다.
* - 제목이 비어 있으면 매달린 선행 구분자(`|`,`-`,`·`,`:`,`/`,`–`,`—`)를 떼어
* 사이트명 부분만 남긴다 (홈처럼 페이지 제목이 없는 화면의 "`| 사이트명`" 방지).
*
* @param string $title 최종 페이지 제목 (filter 훅 적용 후)
* @param string $suffix 코어 설정의 타이틀 접미사
* @return string 조립에 사용할 접미사 (제목이 없으면 접미사가 곧 전체 제목)
*/
public static function composeTitleSuffix(string $title, string $suffix): string
{
if (trim($suffix) === '') {
return '';
}
if ($title === '') {
$stripped = (string) preg_replace('/^[\s|·:\/\x{2013}\x{2014}-]+/u', '', $suffix);
return trim($stripped);
}
return preg_match('/^\s/u', $suffix) === 1 ? $suffix : ' '.$suffix;
}
/**
* 레이아웃 meta의 title을 해석합니다 (fallback용).
*
@@ -691,7 +723,15 @@ class SeoMetaResolver
$resolved = array_merge(['@context' => 'https://schema.org'], $structuredData);
return json_encode($resolved, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
// JSON-LD 는 `<script type="application/ld+json">` 안에 임베드된다. 사용자 제어 값
// (검색어·상품명 등)에 포함된 `</script>` 가 스크립트 컨텍스트를 조기 종료하면 그
// 뒤의 페이로드가 실행 가능한 script 요소로 재생성된다(반사형 XSS — 봇 렌더는
// _escaped_fragment_ 로 일반 UA 도 강제됨). JSON_HEX_TAG 로 `<`·`>` 를 <·>
// 로 이스케이프해 브레이크아웃을 차단한다. JSON_HEX_AMP 는 방어 심화.
return json_encode(
$resolved,
JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_HEX_TAG | JSON_HEX_AMP,
);
}
/**
@@ -790,9 +830,9 @@ class SeoMetaResolver
* 구조화 데이터 하위 객체가 실질적으로 비어있는지 확인합니다.
*
* @type 키가 있는 객체에서, @type 외 필드 중 하나라도 빈 문자열이면
* 해당 객체를 JSON-LD에서 제거합니다.
* 예: aggregateRating의 ratingValue=""이면, bestRating="5"가 있더라도 제거됩니다.
* Google 구조화 데이터 검증에서 필수 필드가 빈 값이면 에러로 처리되기 때문입니다.
* 해당 객체를 JSON-LD에서 제거합니다.
* 예: aggregateRating의 ratingValue=""이면, bestRating="5"가 있더라도 제거됩니다.
* Google 구조화 데이터 검증에서 필수 필드가 빈 값이면 에러로 처리되기 때문입니다.
*
* @param array $resolved 평가된 구조화 데이터 객체
* @return bool 비어있으면 true
+3 -1
View File
@@ -491,7 +491,9 @@ class SeoRenderer implements SeoRendererInterface
$viewData = [
'locale' => $locale,
'title' => $meta['title'],
'titleSuffix' => $meta['titleSuffix'],
// filter 훅이 title 을 바꿨을 수 있으므로 최종 title 기준으로 접미사를 정규화한다
// (TrimStrings 로 선행 공백이 제거된 접미사 복원 + 빈 제목의 매달린 구분자 제거)
'titleSuffix' => SeoMetaResolver::composeTitleSuffix((string) ($meta['title'] ?? ''), (string) ($meta['titleSuffix'] ?? '')),
'description' => $meta['description'],
'keywords' => $meta['keywords'],
'canonicalUrl' => $canonicalUrl,
+78 -5
View File
@@ -591,15 +591,88 @@ class ScheduleCommandValidator
$command = self::findRegisteredCommand($name);
if ($command === null) {
if ($command !== null) {
$class = get_class($command);
foreach ($namespaces as $namespace) {
if (str_starts_with($class, $namespace)) {
return $command->getDefinition();
}
}
return null;
}
$class = get_class($command);
// 레지스트리에 없으면 프로바이더 선언 폴백 — HTTP 요청에서는 확장 프로바이더가
// `runningInConsole()` 게이트로 커맨드 등록을 건너뛰어 `Artisan::all()` 에
// 확장 커맨드가 존재하지 않는다. 관리자 화면의 스케줄 저장 검증이 바로 이
// 문맥이므로, 등록 인스턴스가 없을 때는 활성 프로바이더의 `$commands` 선언을
// 같은 기준(클래스 네임스페이스 + 실제 명령명 대조)으로 해석한다.
return self::resolveProviderDeclaredCommandDefinition($name, $namespaces);
}
foreach ($namespaces as $namespace) {
if (str_starts_with($class, $namespace)) {
return $command->getDefinition();
/**
* 활성 서비스 프로바이더가 `$commands` 프로퍼티로 선언한 확장 커맨드에서
* 명령명을 해석해 정의를 돌려줍니다.
*
* 판정 기준은 레지스트리 경로와 동일하다 — 커맨드 **클래스**의 네임스페이스가
* 확장 네임스페이스여야 하고, 요청된 이름은 그 클래스를 실제 인스턴스화해 얻은
* 선언 명령명과 일치해야 한다(이름만으로 위조할 수 없다). 프로바이더가 커맨드
* 목록을 생성자에서 동적으로 만들면 기본값이 비므로 이 폴백에는 걸리지 않는다
* (fail-closed 유지).
*
* @param string $name 명령명
* @param array<int, string> $namespaces 허용 확장 네임스페이스 접두사
* @return InputDefinition|null 해석 불가하면 null
*/
private static function resolveProviderDeclaredCommandDefinition(string $name, array $namespaces): ?InputDefinition
{
try {
$providers = app()->getLoadedProviders();
} catch (Throwable) {
return null;
}
foreach (array_keys($providers) as $providerClass) {
if (! class_exists($providerClass)) {
continue;
}
try {
$defaults = (new \ReflectionClass($providerClass))->getDefaultProperties();
} catch (Throwable) {
continue;
}
foreach ((array) ($defaults['commands'] ?? []) as $commandClass) {
if (! is_string($commandClass) || ! class_exists($commandClass)) {
continue;
}
$owned = false;
foreach ($namespaces as $namespace) {
if (str_starts_with($commandClass, $namespace)) {
$owned = true;
break;
}
}
if (! $owned) {
continue;
}
try {
/** @var SymfonyCommand $instance */
$instance = app()->make($commandClass);
} catch (Throwable) {
continue;
}
if (! $instance instanceof SymfonyCommand || $instance->getName() !== $name) {
continue;
}
return $instance->getDefinition();
}
}