Skip to content

Instantly share code, notes, and snippets.

View acjh's full-sized avatar

Aaron Chong acjh

View GitHub Profile
@acjh
acjh / stripScripts.swift
Last active January 17, 2022 07:21
Strip <script> tags in Swift
/*
Original question: https://www.facebook.com/groups/swiftiosdev/permalink/840418429450358/
"Attempting to remove HTML markup using a regular expression is problematic.
You don't know what's in there as script or attribute values.
One way is to insert it as the innerHTML of a div, remove any script elements and return the innerHTML"
- RobG , http://stackoverflow.com/a/6660151
"The trick is to base64 encode the data before passing it as the function parameter"
- LJD, https://forums.developer.apple.com/thread/45643#133329