">" inside "a" element "href" attribute causes value truncation
Closed this issue · 7 comments
I am using this very cool package v1.11.66 to add attributes to "a" elements in PHP source code files. I am only running across one snag that does not cause an exception. If I parse an element such as:
<a target="_blank" href="$CFG->wwwroot/course/view.php?id=$course->id">$shortname ->
Instead of getting $CFG->wwwroot/course/view.php?id=$course->id for the "href" attribute value, I only get $CFG-
Note that those are literal \ and not escape characters. I can work around this by changing the HTML to <a target="_blank" href="$CFG->wwwroot/course/view.php?id=$course->id">$shortname -> before parsing it, but it would be nice if this could be handled since it's contained inside the " pair. I'm guessing it's also a possibility that the " containment vs " is causing the problem.
Ah, markdown interfered with my post. Please see attachment.
HAP sample.txt
Also, the attached line does parse properly.
HAP sample 2.txt
Hello @mikehenry1979-bah ,
Thank you for reporting.
We will look at it very soon.
Best Regards,
Jon
Hello @mikehenry1979-bah ,
Do you think you could create a Fiddle or a runnable project with the issue? It doesn’t need to be your project, just a new solution with the minimum code to reproduce the issue.
I just made a simple test and everything is working: https://dotnetfiddle.net/yUfgJW
var document = new HtmlDocument();
document.LoadHtml("<a target=\"_blank\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$shortname</a>");
var href = document.DocumentNode.SelectSingleNode("//a").GetAttributeValue("href", "");
Console.WriteLine(href);
(I also tried when reading a file)
So I'm probably missing something from my simple test. Knowing how to get the same issue as you will surely help me.
Best Regards,
Jon
Hello @mikehenry1979-bah,
Since our last conversation, we haven't heard from you.
As previously mentioned we would need a runnable project to assist you.
Let me know if you have questions.
Best regards,
Jon
Hello @mikehenry1979-bah
Perfect, we will close it.
We will re-open it when you will be able to provide an example.
Best Regards,
Jon