Skip to content

Commit

Permalink
patch: avoid Android crash when svgs use the " html entity
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoloureirop committed Aug 29, 2024
1 parent 5103173 commit 54cabe0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion patches/react-native-svg+15.3.0.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/react-native-svg/src/xml.tsx b/node_modules/react-native-svg/src/xml.tsx
index 34fad47..473ab00 100644
index 34fad47..c5cb578 100644
--- a/node_modules/react-native-svg/src/xml.tsx
+++ b/node_modules/react-native-svg/src/xml.tsx
@@ -124,6 +124,15 @@ export function SvgXml(props: XmlProps) {
Expand All @@ -18,3 +18,16 @@ index 34fad47..473ab00 100644
if (response.ok || (response.status === 0 && uri.startsWith('file://'))) {
return await response.text();
}
@@ -298,7 +307,11 @@ const quotemarks = /['"]/;

export type Middleware = (ast: XmlAST) => XmlAST;

-export function parse(source: string, middleware?: Middleware): JsxAST | null {
+export function parse(sourceUnmodified: string, middleware?: Middleware): JsxAST | null {
+ // Avoid crashes on malformed SVGs from URIs that use the HTML entity " instead of "
+ // react-native-svg team acknowledges this parser needs more work to parse HTML entites correctly
+ // https://github.com/software-mansion/react-native-svg/pull/2426#issuecomment-2306692764
+ const source = sourceUnmodified.replace('"','"');
const length = source.length;
let currentElement: XmlAST | null = null;
let state = metadata;

0 comments on commit 54cabe0

Please sign in to comment.