mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Fix xpath comment element parsing (#759)
This commit is contained in:
@@ -189,8 +189,9 @@ func (q *xpathQuery) nodeText(n *html.Node) string {
|
|||||||
var ret string
|
var ret string
|
||||||
if n != nil && n.Type == html.CommentNode {
|
if n != nil && n.Type == html.CommentNode {
|
||||||
ret = htmlquery.OutputHTML(n, true)
|
ret = htmlquery.OutputHTML(n, true)
|
||||||
}
|
} else {
|
||||||
ret = htmlquery.InnerText(n)
|
ret = htmlquery.InnerText(n)
|
||||||
|
}
|
||||||
|
|
||||||
// trim all leading and trailing whitespace
|
// trim all leading and trailing whitespace
|
||||||
ret = strings.TrimSpace(ret)
|
ret = strings.TrimSpace(ret)
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ const htmlDoc1 = `
|
|||||||
<b>Piercings:</b>
|
<b>Piercings:</b>
|
||||||
</td>
|
</td>
|
||||||
<td class="paramvalue">
|
<td class="paramvalue">
|
||||||
None
|
<!-- None -->;
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -193,7 +193,7 @@ func makeXPathConfig() mappedPerformerScraperConfig {
|
|||||||
config.mappedConfig["Measurements"] = makeSimpleAttrConfig(makeCommonXPath("Measurements:"))
|
config.mappedConfig["Measurements"] = makeSimpleAttrConfig(makeCommonXPath("Measurements:"))
|
||||||
config.mappedConfig["FakeTits"] = makeSimpleAttrConfig(makeCommonXPath("Fake boobs:"))
|
config.mappedConfig["FakeTits"] = makeSimpleAttrConfig(makeCommonXPath("Fake boobs:"))
|
||||||
config.mappedConfig["Tattoos"] = makeSimpleAttrConfig(makeCommonXPath("Tattoos:"))
|
config.mappedConfig["Tattoos"] = makeSimpleAttrConfig(makeCommonXPath("Tattoos:"))
|
||||||
config.mappedConfig["Piercings"] = makeSimpleAttrConfig(makeCommonXPath("Piercings:"))
|
config.mappedConfig["Piercings"] = makeSimpleAttrConfig(makeCommonXPath("Piercings:") + "/comment()")
|
||||||
|
|
||||||
// special handling for birthdate
|
// special handling for birthdate
|
||||||
birthdateAttrConfig := makeSimpleAttrConfig(makeCommonXPath("Date of Birth:"))
|
birthdateAttrConfig := makeSimpleAttrConfig(makeCommonXPath("Date of Birth:"))
|
||||||
@@ -295,7 +295,8 @@ func TestScrapePerformerXPath(t *testing.T) {
|
|||||||
const measurements = "34C-26-36"
|
const measurements = "34C-26-36"
|
||||||
const fakeTits = "No"
|
const fakeTits = "No"
|
||||||
const careerLength = "2012 - 2019"
|
const careerLength = "2012 - 2019"
|
||||||
const tattoosPiercings = "None"
|
const tattoos = "None"
|
||||||
|
const piercings = "<!-- None -->"
|
||||||
const gender = "Female"
|
const gender = "Female"
|
||||||
const height = "170"
|
const height = "170"
|
||||||
|
|
||||||
@@ -313,8 +314,8 @@ func TestScrapePerformerXPath(t *testing.T) {
|
|||||||
|
|
||||||
verifyField(t, careerLength, performer.CareerLength, "CareerLength")
|
verifyField(t, careerLength, performer.CareerLength, "CareerLength")
|
||||||
|
|
||||||
verifyField(t, tattoosPiercings, performer.Tattoos, "Tattoos")
|
verifyField(t, tattoos, performer.Tattoos, "Tattoos")
|
||||||
verifyField(t, tattoosPiercings, performer.Piercings, "Piercings")
|
verifyField(t, piercings, performer.Piercings, "Piercings")
|
||||||
verifyField(t, height, performer.Height, "Height")
|
verifyField(t, height, performer.Height, "Height")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user