Avoid crashing on unexpected color strings
This commit is contained in:
committed by
GitHub
parent
1e49ab4e85
commit
c7dcf78d11
@@ -593,19 +593,31 @@ public struct MTMathListBuilder {
|
|||||||
} else if command == "color" {
|
} else if command == "color" {
|
||||||
// A color command has 2 arguments
|
// A color command has 2 arguments
|
||||||
let mathColor = MTMathColor()
|
let mathColor = MTMathColor()
|
||||||
mathColor.colorString = self.readColor()!
|
let color = self.readColor()
|
||||||
|
if color == nil {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
mathColor.colorString = color!
|
||||||
mathColor.innerList = self.buildInternal(true)
|
mathColor.innerList = self.buildInternal(true)
|
||||||
return mathColor
|
return mathColor
|
||||||
} else if command == "textcolor" {
|
} else if command == "textcolor" {
|
||||||
// A textcolor command has 2 arguments
|
// A textcolor command has 2 arguments
|
||||||
let mathColor = MTMathTextColor()
|
let mathColor = MTMathTextColor()
|
||||||
mathColor.colorString = self.readColor()!
|
let color = self.readColor()
|
||||||
|
if color == nil {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
mathColor.colorString = color!
|
||||||
mathColor.innerList = self.buildInternal(true)
|
mathColor.innerList = self.buildInternal(true)
|
||||||
return mathColor
|
return mathColor
|
||||||
} else if command == "colorbox" {
|
} else if command == "colorbox" {
|
||||||
// A color command has 2 arguments
|
// A color command has 2 arguments
|
||||||
let mathColorbox = MTMathColorbox()
|
let mathColorbox = MTMathColorbox()
|
||||||
mathColorbox.colorString = self.readColor()!
|
let color = self.readColor()
|
||||||
|
if color == nil {
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
mathColor.colorString = color!
|
||||||
mathColorbox.innerList = self.buildInternal(true)
|
mathColorbox.innerList = self.buildInternal(true)
|
||||||
return mathColorbox
|
return mathColorbox
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user