Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apparent regression in 2.7.3 #277

Closed
DD-P opened this issue Jul 31, 2024 · 6 comments
Closed

Apparent regression in 2.7.3 #277

DD-P opened this issue Jul 31, 2024 · 6 comments

Comments

@DD-P
Copy link

DD-P commented Jul 31, 2024

HTML with Javascript containing CDATA and '&&' hangs on parsing. This first occurs with commit fc06146

A test case modified from here is

import SwiftSoup
import XCTest

class SwiftSoupTests: XCTestCase {
	func testJavaScriptWithCDATA() throws {
		let html = """
			<!DOCTYPE html>
			<html>
			<body>

			<h1>JavaScript Comparison</h1>
			<h2>The && Operator (Logical AND)</h2>
			<p>The && operator returns true if both expressions are true, otherwise it returns false.</p>

			<p id="demo"></p>

			<script>
			<!--//--><![CDATA[//><!--
			let x = 6;
			let y = 3;

			document.getElementById("demo").innerHTML = 
			(x < 10 && y > 1) + "<br>" + 
			(x < 10 && y < 1);
			//--><!]]>
			</script>

			</body>
			</html>
		"""
		_ = try SwiftSoup.parse(html)
	}
}
@aehlke
Copy link
Collaborator

aehlke commented Aug 2, 2024

Sorry, that was my regression

I confirm that this test hangs

@aehlke
Copy link
Collaborator

aehlke commented Aug 2, 2024

Minimal test case which hangs:

            <!DOCTYPE html>
            <script>
            <!--//-->
            &
            </script>

not CDATA, but something with the combination of the comment tag + the ampersand

@aehlke
Copy link
Collaborator

aehlke commented Aug 2, 2024

I fixed it in this PR: #276

@aehlke
Copy link
Collaborator

aehlke commented Aug 15, 2024

Released: https://github.com/scinfu/SwiftSoup/releases/tag/2.7.4

@aehlke aehlke closed this as completed Aug 15, 2024
@moehrenzahn
Copy link

Hi, I just wanted to quickly say thanks for your efforts to keep this library updated and working. I just ran into this issue on 2.7.3 and am highly relieved that a fix is already available. You are awesome!

@aehlke
Copy link
Collaborator

aehlke commented Aug 19, 2024

@moehrenzahn np, I appreciate the kind words. I'm using it in production for my own app that I've gone full-time on (Manabi Reader https://reader.manabi.io for learning Japanese) and now that I've made it fast enough to continue using, I'll be sticking with it likely for years to come. Can't promise continued stewardship but I'm happy to see through a couple upgrades so far at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants