@@ 95,6 95,9 @@ func getCVEs(bulletin bulletin) (entries []entry) {
}
doc.Find("h2").Each(func(_ int, patchLevelHeading *goquery.Selection) {
+ if !strings.HasPrefix(patchLevelHeading.Text(), "20") {
+ return
+ }
patchLevel := strings.Fields(patchLevelHeading.Text())[0]
patchLevelHeading.NextFilteredUntil("h3", "h2").Each(func(_ int, componentHeading *goquery.Selection) {
component := shave(componentHeading.Text())
@@ 104,8 107,8 @@ func getCVEs(bulletin bulletin) (entries []entry) {
rows := colgroup.Next().Find("tr")
headingRow := rows.First()
- nColumns := headingRow.Find("th").Length()
- position := getHeadingPositions(headingRow.Children())
+ headingCells := headingRow.Find("th")
+ nColumns := headingCells.Length()
savedRowspans := make([]rowspanCounter, nColumns)
headingRow.NextAll().Each(func(_ int, row *goquery.Selection) {
@@ 113,17 116,14 @@ func getCVEs(bulletin bulletin) (entries []entry) {
if cells.Length() < nColumns {
for index, rowspanData := range savedRowspans {
- if rowspanData.rowsLeft < 1 {
- continue
+ if rowspanData.rowsLeft > 0 {
+ cells.Eq(index).BeforeSelection(rowspanData.pop())
}
-
- //cells.insert(index, rowspanData.pop())
- cells.Eq(index).BeforeSelection(rowspanData.pop())
}
+ // the document has been modified, so the selection must be refreshed
+ cells = row.Find("td")
}
- // the document has been modified, but the selection must be refreshed
- cells = row.Find("td")
cells.Each(func(index int, cell *goquery.Selection) {
if _, ok := cell.Attr("rowspan"); ok {
savedRowspans[index] = newRowspanCounter(cell.Clone())
@@ 137,17 137,24 @@ func getCVEs(bulletin bulletin) (entries []entry) {
cells.Each(func(index int, cell *goquery.Selection) {
text := shave(cell.Text())
- switch position[index] {
- case "cve":
+ heading := headingCells.Eq(index).Text()
+ switch heading {
+ case "CVE":
e.cve = text
- case "type":
+ case "Type":
e.Type = text
- case "severity":
+ case "Severity", "Severity*":
e.severity = text
- case "versions":
+ case "Updated AOSP versions":
e.versions = strings.Split(cell.Text(), ", ")
- case "component":
+ case "Component":
e.component2 = text
+ case "References", "Abbreviation", "Definition", "Prefix", "Reference",
+ "Version", "Date", "Notes", "Date reported", "Updated Google devices",
+ "Updated Nexus devices", "CVEs", "Android bug", "Android bugs", "":
+ // these table headings are ignored
+ default:
+ fmt.Fprintf(os.Stderr, "unexpected table heading %q\n", heading)
}
})
@@ 158,31 165,6 @@ func getCVEs(bulletin bulletin) (entries []entry) {
return entries
}
-func getHeadingPositions(headingRowCells *goquery.Selection) map[int]string {
- position := make(map[int]string)
- headingRowCells.Each(func(i int, heading *goquery.Selection) {
- switch heading.Text() {
- case "CVE":
- position[i] = "cve"
- case "Severity", "Severity*":
- position[i] = "severity"
- case "Updated AOSP versions":
- position[i] = "versions"
- case "Type":
- position[i] = "type"
- case "Component":
- position[i] = "component"
- case "References", "Abbreviation", "Definition", "Prefix", "Reference",
- "Version", "Date", "Notes", "Date reported", "Updated Google devices",
- "Updated Nexus devices", "CVEs", "Android bug", "Android bugs", "":
- // these table headings are ignored
- default:
- fmt.Fprintf(os.Stderr, "unexpected table heading %q\n", heading.Text())
- }
- })
- return position
-}
-
type rowspanCounter struct {
rowsLeft int
value *goquery.Selection