From f5ca78d562698465a9069f99d84e4bd4ed2a7a14 Mon Sep 17 00:00:00 2001 From: yoonieaj Date: Sun, 27 Jul 2025 21:28:11 -0400 Subject: [PATCH 1/3] Fix bug where parsing graphs would crash --- app/Svg/Parser.hs | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/app/Svg/Parser.hs b/app/Svg/Parser.hs index e3f915d89..ce62aa416 100644 --- a/app/Svg/Parser.hs +++ b/app/Svg/Parser.hs @@ -180,26 +180,31 @@ parseTextHelper :: GraphId -- ^ The Text's corresponding graph identifier. -> [Text] parseTextHelper _ _ _ _ [] = [] parseTextHelper key styles' trans globalTrans (headTag:restTags) = - let [[a, c, e], [b, d, f], _] = completeTrans - in [Text key - (fromAttrib "id" headTag) -- TODO: Why are we setting an id? - (readAttr "x" headTag, readAttr "y" headTag) - (TS.escapeHTML $ trim $ TS.innerText (headTag:restTags)) - align - fill - [a, b, c, d, e, f] - ] + if not $ any (TS.isTagOpenName "tspan") restTags + then + let [[a, c, e], [b, d, f], _] = completeTrans + in [Text key + (fromAttrib "id" headTag) -- TODO: Why are we setting an id? + (readAttr "x" headTag, readAttr "y" headTag) + (TS.escapeHTML $ trim $ TS.innerText (headTag:restTags)) + align + fill + [a, b, c, d, e, f] + ] + else + let tspanTags = TS.partitions (TS.isTagOpenName "tspan") (headTag:restTags) + in + concatMap (parseTextHelper key newStyle newTrans globalTrans) tspanTags where - newStyle = styles headTag ++ styles' - currTrans = getTransform headTag - newTrans = matrixMultiply trans currTrans - completeTrans = matrixMultiply globalTrans newTrans - alignAttr = styleVal "text-anchor" newStyle - align = if T.null alignAttr - then "start" - else alignAttr - fill = styleVal "fill" newStyle - + newStyle = styles headTag ++ styles' + currTrans = getTransform headTag + newTrans = matrixMultiply trans currTrans + completeTrans = matrixMultiply globalTrans newTrans + alignAttr = styleVal "text-anchor" newStyle + align = if T.null alignAttr + then "start" + else alignAttr + fill = styleVal "fill" newStyle -- | Create a rectangle from a list of attributes. parseRect :: Matrix From 71ffd67a6467ed0713fffd8cd6fca3743141f685 Mon Sep 17 00:00:00 2001 From: yoonieaj Date: Sun, 27 Jul 2025 21:29:03 -0400 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b4716313..d3d4a0420 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -126,6 +126,7 @@ - Correctly handle `'l'` directives in svg path attributes - Fixed bug that prevented timetable information from loading in Grid page - Fixed bug that prevented the course info modal from displaying in Grid page +- Fixed bug that led code to crash when parsing graphs from svg ### 🔧 Internal changes From 910c26c993e9580851bba42c380b85d0c87ea66c Mon Sep 17 00:00:00 2001 From: yoonieaj Date: Thu, 14 Aug 2025 22:01:59 -0400 Subject: [PATCH 3/3] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f6b99f64..7017f6ca4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Fixed a bug that was causing the focus info popup to appear blank - Fixed a bug on the generate page causing extraneous ellipses to appear when hovering over a course to highlight its prerequisites - Fixed a bug on the generate page where an extraneous info popup would appear when hovering over the top left corner of the graph viewing window +- Fixed a bug that led code to crash when parsing all pre-generated graphs from svg (i.e., program graphs) ### 🔧 Internal changes @@ -129,7 +130,6 @@ - Correctly handle `'l'` directives in svg path attributes - Fixed bug that prevented timetable information from loading in Grid page - Fixed bug that prevented the course info modal from displaying in Grid page -- Fixed bug that led code to crash when parsing graphs from svg ### 🔧 Internal changes