Merge pull request #5198 from dotCooCoo/fix/ai-open-group-at-end

.ai import: a group still open at the end of the art is an error
This commit is contained in:
BFlat
2026-11-02 14:52:06 +07:00
committed by GitHub
28 changed files with 47 additions and 1 deletions
+7 -1
View File
@@ -69,7 +69,7 @@
//!
//! Sections the reader doesn't need (brushes, symbols, styles, filters) are skipped;
//! type, symbols, fills with a pattern it can't read, placed files without a preview and operators
//! it doesn't know are errors.
//! it doesn't know are errors. So is data that ends inside a layer, a group or a compound path.
use std::collections::{BTreeSet, HashMap, HashSet};
use std::rc::Rc;
@@ -456,6 +456,12 @@ impl<'a> Reader<'a> {
}
}
}
// A pattern's or symbol's reader opens a group of its own and checks it is the only frame
// left. In the document, a container still open after the last layer holds art no layer has.
let in_layer = self.frames.iter().any(|f| matches!(f.kind, Kind::Layer(_)));
if self.subreader_depth == 0 && !in_layer && self.frames.iter().any(|f| !matches!(f.kind, Kind::Obj(_) | Kind::Mask)) {
return Err("it ends inside a group or compound path".into());
}
if self.frames.iter().any(|f| matches!(f.kind, Kind::Layer(_))) {
return Err("it ends inside a layer".into());
}
+14
View File
@@ -1748,6 +1748,20 @@ fn what_it_doesnt_read_is_an_error_where_it_shows() {
read_ok(&format!("Adobe_level2_AI5 /initialize get exec\n{}", layer("")));
}
#[test]
fn a_group_still_open_at_the_end_is_an_error() {
let square = format!("{}f\n", rect_path(0.0, 0.0, 10.0, 10.0));
for open in ["u", "q", "*u", "%_u"] {
let e = read(stream(&format!("{}{open}\n{square}", layer(""))).as_bytes()).unwrap_err();
assert_eq!(e, "it ends inside a group or compound path", "{open}");
}
// A group open inside a layer that doesn't end is the layer's error.
let unended = format!("%AI5_BeginLayer\n1 1 1 1 0 0 1 0 79 128 255 0 50 0 Lb\n(L) Ln\nu\n{square}");
assert_eq!(read(stream(&unended).as_bytes()).unwrap_err(), "it ends inside a layer");
// Patterns read with a group of their own still read.
assert!(read_ok(&format!("{DOTS}{}", layer(""))).doc.pattern("Dots").is_some());
}
#[test]
fn unresolved_pattern_reset_before_group_path_keeps_live_art() {
for (operator, draw, reset) in [("p", "f", "0 0 0 1 k"), ("P", "S", "0 0 0 1 K")] {
+1
View File
@@ -4439,6 +4439,7 @@ axis Both И двете
@msg `{what}` closes nothing `{what}` не затваря нищо
@msg `{what}` closes something it didn't open `{what}` затваря нещо, което не е отворило
@msg a path has too many points пътят има твърде много точки
@msg it ends inside a group or compound path той завършва вътре в група или съставен път
@msg it ends inside a layer той завършва вътре в слой
@msg it has art outside its layers той има обекти извън своите слоеве
@msg it has more than {MAX_NODES} objects той има повече от {MAX_NODES} обекта
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4841,6 +4841,7 @@ imageTrace Outline Obris
@msg `{what}` closes nothing `{what}` ne zatvara ništa
@msg `{what}` closes something it didn't open `{what}` zatvara nešto što nije otvorio
@msg a path has too many points putanja ima previše tačaka
@msg it ends inside a group or compound path završava unutar grupe ili složene putanje
@msg it ends inside a layer završava unutar sloja
@msg it has art outside its layers ima crtež izvan svojih slojeva
@msg it has more than {MAX_NODES} objects ima više od {MAX_NODES} objekata
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -5061,6 +5061,7 @@ digits Malayalam Malaiàlam
@msg invalid stroke widths amplades de traç no vàlides
@msg is not an image VectorCraft reads no és una imatge que VectorCraft pugui llegir
@msg it decompresses to more than {_1} MB es descomprimeix fins a més de {_1} MB
@msg it ends inside a group or compound path acaba dins d’un grup o d’un traçat compost
@msg it ends inside a layer acaba dins d’una capa
@msg it ends inside a multi-layer mask acaba dins d’una màscara multicapa
@msg a multi-layer mask's operators are out of order els operadors d’una màscara multicapa estan desordenats
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4890,6 +4890,7 @@ imageTrace Outline Obrys
@msg `{w}` takes no operands `{w}` nepřijímá žádné operandy
@msg a wraparound group is inside a compound path skupina obtékání textu je uvnitř složené cesty
@msg a path has too many points cesta má příliš mnoho bodů
@msg it ends inside a group or compound path končí uvnitř skupiny nebo složené cesty
@msg it ends inside a layer končí uvnitř vrstvy
@msg it ends inside a multi-layer mask končí uvnitř masky přes více vrstev
@msg a multi-layer mask's operators are out of order operátory masky přes více vrstev jsou ve špatném pořadí
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4530,6 +4530,7 @@ imageTrace Outline Kontur
@msg `{what}` closes nothing `{what}` lukker intet
@msg `{what}` closes something it didn't open `{what}` lukker noget, den ikke åbnede
@msg a path has too many points en sti har for mange punkter
@msg it ends inside a group or compound path den slutter inde i en gruppe eller en sammensat kurve
@msg it ends inside a layer den slutter inde i et lag
@msg it has art outside its layers den har grafik uden for sine lag
@msg it has more than {MAX_NODES} objects den har flere end {MAX_NODES} objekter
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4499,6 +4499,7 @@ theme Appearance Erscheinungsbild
@msg `{w}` takes no operands `{w}` nimmt keine Operanden
@msg a wraparound group is inside a compound path eine Textumfluss-Gruppe liegt in einem zusammengesetzten Pfad
@msg a path has too many points ein Pfad hat zu viele Punkte
@msg it ends inside a group or compound path es endet innerhalb einer Gruppe oder eines zusammengesetzten Pfads
@msg it ends inside a layer es endet innerhalb einer Ebene
@msg it ends inside a multi-layer mask es endet innerhalb einer ebenenübergreifenden Maske
@msg a multi-layer mask's operators are out of order die Operatoren einer ebenenübergreifenden Maske stehen in falscher Reihenfolge
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4532,6 +4532,7 @@ digits Malayalam Μαλαγιάλαμ
@msg `{w}` takes no operands το `{w}` δεν δέχεται τελεστέους
@msg a wraparound group is inside a compound path μια ομάδα αναδίπλωσης κειμένου βρίσκεται μέσα σε σύνθετη διαδρομή
@msg a path has too many points η διαδρομή έχει υπερβολικά πολλά σημεία
@msg it ends inside a group or compound path τερματίζει μέσα σε ομάδα ή σύνθετη διαδρομή
@msg it ends inside a layer τερματίζει μέσα σε επίπεδο
@msg it ends inside a multi-layer mask τερματίζει μέσα σε μάσκα πολλών επιπέδων
@msg a multi-layer mask's operators are out of order οι τελεστές μιας μάσκας πολλών επιπέδων είναι σε λάθος σειρά
Can't render this file because it contains an unexpected character in line 163 and column 5.
+1
View File
@@ -4584,6 +4584,7 @@ axis Both Ambos
@msg `{w}` takes no operands `{w}` no admite operandos
@msg a wraparound group is inside a compound path un grupo de ceñir texto está dentro de un trazado compuesto
@msg a path has too many points un trazado tiene demasiados puntos
@msg it ends inside a group or compound path terminan dentro de un grupo o un trazado compuesto
@msg it ends inside a layer terminan dentro de una capa
@msg it ends inside a multi-layer mask terminan dentro de una máscara de varias capas
@msg a multi-layer mask's operators are out of order los operadores de una máscara de varias capas están desordenados
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4792,6 +4792,7 @@ imageTrace Outline Ääriviiva
@msg `{w}` takes no operands `{w}` ei ota operandeja
@msg a wraparound group is inside a compound path tekstin rivitysryhmä on yhdistelmäpolun sisällä
@msg a path has too many points polulla on liian monta pistettä
@msg it ends inside a group or compound path se päättyy ryhmän tai yhdistelmäpolun sisään
@msg it ends inside a layer se päättyy tason sisään
@msg it ends inside a multi-layer mask se päättyy monitasoisen maskin sisään
@msg a multi-layer mask's operators are out of order monitasoisen maskin operaattorit ovat väärässä järjestyksessä
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4574,6 +4574,7 @@ axis Both Les deux
@msg `{w}` takes no operands `{w}` n’accepte aucun opérande
@msg a wraparound group is inside a compound path un groupe d’habillage de texte se trouve dans un tracé transparent
@msg a path has too many points un tracé a trop de points
@msg it ends inside a group or compound path elles se terminent à l’intérieur d’un groupe ou d’un tracé transparent
@msg it ends inside a layer elles se terminent à l’intérieur d’un calque
@msg it ends inside a multi-layer mask elles se terminent à l’intérieur d’un masque multicalque
@msg a multi-layer mask's operators are out of order les opérateurs d’un masque multicalque sont dans le désordre
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4775,6 +4775,7 @@ imageTrace Outline Körvonal
@msg invalid PDF setting: {0} érvénytelen PDF-beállítás: {0}
@msg invalid restored panel group érvénytelen visszaállított panelcsoport
@msg is not an image VectorCraft reads nem olyan kép, amelyet a VectorCraft olvas
@msg it ends inside a group or compound path egy csoporton vagy összetett útvonalon belül ér véget
@msg it ends inside a layer egy rétegen belül ér véget
@msg it ends inside a multi-layer mask egy többrétegű maszkon belül ér véget
@msg a multi-layer mask's operators are out of order egy többrétegű maszk operátorai rossz sorrendben vannak
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4530,6 +4530,7 @@ imageTrace Outline Kontur
@msg `{what}` closes nothing `{what}` tidak menutup apa pun
@msg `{what}` closes something it didn't open `{what}` menutup sesuatu yang tidak dibukanya
@msg a path has too many points sebuah jalur memiliki terlalu banyak titik
@msg it ends inside a group or compound path berakhir di dalam grup atau jalur majemuk
@msg it ends inside a layer berakhir di dalam lapisan
@msg it has art outside its layers memiliki karya seni di luar lapisannya
@msg it has more than {MAX_NODES} objects memiliki lebih dari {MAX_NODES} objek
Can't render this file because it contains an unexpected character in line 2196 and column 5.
+1
View File
@@ -4625,6 +4625,7 @@ axis Both Entrambi
@msg `{w}` takes no operands `{w}` non accetta operandi
@msg a wraparound group is inside a compound path un gruppo di testo attorno si trova in un tracciato composto
@msg a path has too many points un tracciato ha troppi punti
@msg it ends inside a group or compound path terminano all'interno di un gruppo o di un tracciato composto
@msg it ends inside a layer terminano all'interno di un livello
@msg it ends inside a multi-layer mask terminano all'interno di una maschera multilivello
@msg a multi-layer mask's operators are out of order gli operatori di una maschera multilivello non sono in ordine
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4319,6 +4319,7 @@ swatch Bright Violet ビビッドバイオレット
@msg `{w}` takes no operands `{w}` はオペランドを取りません
@msg a wraparound group is inside a compound path テキストの回り込みグループが複合パスの中にあります
@msg a path has too many points ポイントが多すぎるパスがあります
@msg it ends inside a group or compound path グループまたは複合パスの途中で終わっています
@msg it ends inside a layer レイヤーの途中で終わっています
@msg it ends inside a multi-layer mask 複数レイヤーにまたがるマスクの途中で終わっています
@msg a multi-layer mask's operators are out of order 複数レイヤーにまたがるマスクの演算子の順序が正しくありません
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4323,6 +4323,7 @@ font-technology Variable ცვლადი
@msg `{w}` takes no operands `{w}` ოპერანდებს არ იღებს
@msg a wraparound group is inside a compound path ტექსტის გარსშემოვლების ჯგუფი შედგენილი ტრაექტორიის შიგნითაა
@msg a path has too many points ტრაექტორიას ზედმეტად ბევრი წერტილი აქვს
@msg it ends inside a group or compound path ის ჯგუფის ან შედგენილი ტრაექტორიის შიგნით მთავრდება
@msg it ends inside a layer ის შრის შიგნით მთავრდება
@msg it ends inside a multi-layer mask ის მრავალშრიანი ნიღბის შიგნით მთავრდება
@msg a multi-layer mask's operators are out of order მრავალშრიანი ნიღბის ოპერატორები არასწორი თანმიმდევრობითაა
Can't render this file because it is too large.
+1
View File
@@ -4246,6 +4246,7 @@ theme Appearance 외관
@msg `{w}` takes no operands `{w}`은(는) 피연산자를 받지 않습니다
@msg a wraparound group is inside a compound path 문자 감싸기 그룹이 컴파운드 패스 안에 있습니다
@msg a path has too many points 패스의 점이 너무 많습니다
@msg it ends inside a group or compound path 그룹 또는 컴파운드 패스 안에서 끝납니다
@msg it ends inside a layer 레이어 안에서 끝납니다
@msg it ends inside a multi-layer mask 여러 레이어 마스크 안에서 끝납니다
@msg a multi-layer mask's operators are out of order 여러 레이어 마스크의 연산자 순서가 잘못되었습니다
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4542,6 +4542,7 @@ imageTrace Outline Contour
@msg `{what}` closes nothing `{what}` sluit niets
@msg `{what}` closes something it didn't open `{what}` sluit iets dat het niet heeft geopend
@msg a path has too many points een pad heeft te veel punten
@msg it ends inside a group or compound path het eindigt binnen een groep of samengesteld pad
@msg it ends inside a layer het eindigt binnen een laag
@msg it has art outside its layers het heeft illustratie buiten zijn lagen
@msg it has more than {MAX_NODES} objects het heeft meer dan {MAX_NODES} objecten
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4716,6 +4716,7 @@ imageTrace Outline Kontur
@msg `{w}` takes no operands `{w}` nie przyjmuje operandów
@msg a wraparound group is inside a compound path grupa oblewania tekstem jest wewnątrz ścieżki złożonej
@msg a path has too many points ścieżka ma zbyt wiele punktów
@msg it ends inside a group or compound path kończy się wewnątrz grupy lub ścieżki złożonej
@msg it ends inside a layer kończy się wewnątrz warstwy
@msg it ends inside a multi-layer mask kończy się wewnątrz maski wielowarstwowej
@msg a multi-layer mask's operators are out of order operatory maski wielowarstwowej są w złej kolejności
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4172,6 +4172,7 @@ axis Both Ambos
@msg `{w}` takes no operands `{w}` não aceita operandos
@msg a wraparound group is inside a compound path um grupo de quebra de texto está dentro de um traçado composto
@msg a path has too many points um traçado tem pontos demais
@msg it ends inside a group or compound path termina dentro de um grupo ou caminho composto
@msg it ends inside a layer termina dentro de uma camada
@msg it ends inside a multi-layer mask termina dentro de uma máscara de várias camadas
@msg a multi-layer mask's operators are out of order os operadores de uma máscara de várias camadas estão fora de ordem
Can't render this file because it contains an unexpected character in line 6 and column 47.
+1
View File
@@ -4620,6 +4620,7 @@ axis Both Оба
@msg `{w}` takes no operands `{w}` не принимает операндов
@msg a wraparound group is inside a compound path группа обтекания текстом находится внутри составного контура
@msg a path has too many points в контуре слишком много точек
@msg it ends inside a group or compound path они заканчиваются внутри группы или составного контура
@msg it ends inside a layer они заканчиваются внутри слоя
@msg it ends inside a multi-layer mask они заканчиваются внутри многослойной маски
@msg a multi-layer mask's operators are out of order операторы многослойной маски идут в неправильном порядке
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -4483,6 +4483,7 @@ axis Both Båda
@msg `{w}` takes no operands `{w}` tar inga operander
@msg a wraparound group is inside a compound path en textombrytningsgrupp ligger inuti en sammansatt bana
@msg a path has too many points en bana har för många punkter
@msg it ends inside a group or compound path den slutar inuti en grupp eller en sammansatt bana
@msg it ends inside a layer den slutar inuti ett lager
@msg it ends inside a multi-layer mask den slutar inuti en flerlagersmask
@msg a multi-layer mask's operators are out of order operatorerna för en flerlagersmask står i fel ordning
Can't render this file because it contains an unexpected character in line 5 and column 25.
+1
View File
@@ -4321,6 +4321,7 @@ axis Both Her İkisi
@msg `{w}` takes no operands `{w}` işlenen almaz
@msg a wraparound group is inside a compound path bir metin kaydırma grubu bileşik bir yolun içinde
@msg a path has too many points bir yolun çok fazla noktası var
@msg it ends inside a group or compound path bir grubun veya bileşik yolun içinde bitiyor
@msg it ends inside a layer bir katmanın içinde bitiyor
@msg it ends inside a multi-layer mask çok katmanlı bir maskenin içinde bitiyor
@msg a multi-layer mask's operators are out of order çok katmanlı bir maskenin işleçleri yanlış sırada
Can't render this file because it contains an unexpected character in line 5 and column 25.
+1
View File
@@ -4609,6 +4609,7 @@ axis Both Обидві
@msg `{w}` takes no operands `{w}` не приймає операндів
@msg a wraparound group is inside a compound path група обтікання текстом розташована всередині складеного контуру
@msg a path has too many points у контурі занадто багато точок
@msg it ends inside a group or compound path вони закінчуються всередині групи або складеного контуру
@msg it ends inside a layer вони закінчуються всередині шару
@msg it ends inside a multi-layer mask вони закінчуються всередині багатошарової маски
@msg a multi-layer mask's operators are out of order оператори багатошарової маски йдуть у неправильному порядку
Can't render this file because it contains an unexpected character in line 177 and column 5.
+1
View File
@@ -4425,6 +4425,7 @@ theme Appearance Giao diện
@msg invalid PDF setting: {0} cài đặt PDF không hợp lệ: {0}
@msg invalid restored panel group nhóm bảng được phục hồi không hợp lệ
@msg is not an image VectorCraft reads không phải ảnh mà VectorCraft đọc được
@msg it ends inside a group or compound path nó kết thúc bên trong một nhóm hoặc đường dẫn phức
@msg it ends inside a layer nó kết thúc bên trong một lớp
@msg it ends inside a multi-layer mask nó kết thúc bên trong một mặt nạ nhiều lớp
@msg a multi-layer mask's operators are out of order các toán tử của mặt nạ nhiều lớp không đúng thứ tự
Can't render this file because it contains an unexpected character in line 199 and column 5.
+1
View File
@@ -4044,6 +4044,7 @@ imageTrace Outline 轮廓
@msg `{w}` takes no operands `{w}` 不接受操作数
@msg a wraparound group is inside a compound path 文本绕排组位于复合路径内
@msg a path has too many points 某条路径的点过多
@msg it ends inside a group or compound path 它在编组或复合路径内部结束
@msg it ends inside a layer 它在图层内部结束
@msg it ends inside a multi-layer mask 它在跨图层蒙版内部结束
@msg a multi-layer mask's operators are out of order 跨图层蒙版的运算符顺序错误
Can't render this file because it contains an unexpected character in line 2 and column 73.
+1
View File
@@ -1964,6 +1964,7 @@ file-filter Templates 範本
@msg `{w}` takes no operands `{w}` 不接受運算元
@msg a wraparound group is inside a compound path 文字繞圖群組位於複合路徑內
@msg a path has too many points 有一條路徑的點過多
@msg it ends inside a group or compound path 它在群組或複合路徑內部結束
@msg it ends inside a layer 它在圖層內部結束
@msg it ends inside a multi-layer mask 它在跨圖層遮色片內部結束
@msg a multi-layer mask's operators are out of order 跨圖層遮色片的運算子順序錯誤
Can't render this file because it contains an unexpected character in line 6 and column 47.