From a5c92aa48a180114a0ff7c561dd0c1bd9f7afbde Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 7 Jan 2020 11:19:43 +0100 Subject: [PATCH] Add Tracking Vector Text metadata And align with defaults used in https://github.com/whatwg/wattsi/pull/41. --- bikeshed/fingerprinting.py | 9 ++++----- bikeshed/metadata.py | 4 +++- tests/fingerprint001.html | 8 ++++---- tests/fingerprint003.bs | 4 ++-- tests/fingerprint003.html | 10 +++++----- tests/fingerprint004.html | 4 ++-- tests/fingerprint005.html | 6 +++--- tests/fingerprint006.html | 6 +++--- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/bikeshed/fingerprinting.py b/bikeshed/fingerprinting.py index 095310d606..0407f9ae3e 100644 --- a/bikeshed/fingerprinting.py +++ b/bikeshed/fingerprinting.py @@ -29,14 +29,13 @@ def addTrackingVector(doc): for el in els: prependChild(el, - trackingVectorImage(doc.md.trackingVectorImage, doc.md.trackingVectorTitle, doc.md.trackingVectorClass)) + trackingVectorImage(doc.md.trackingVectorImage, doc.md.trackingVectorText, doc.md.trackingVectorTitle, doc.md.trackingVectorClass)) removeAttr(el, "tracking-vector") - -def trackingVectorImage(url, title, cls): +def trackingVectorImage(url, text, title, cls): if url is None: - return E.svg({"width":"46", "height":"64", "role":"img", "class": cls}, + return E.svg({"width":"46", "height":"64", "role":"img", "aria-label":text, "class":cls}, E.title({}, title), E.use({"href":"#"+trackingVectorId})) else: - return E.img({"title":title, "alt":title, "src":url, "class": cls}) + return E.img({"title":title, "alt":text, "src":url, "class":cls}) diff --git a/bikeshed/metadata.py b/bikeshed/metadata.py index 03861f41ee..239a42ff02 100644 --- a/bikeshed/metadata.py +++ b/bikeshed/metadata.py @@ -69,7 +69,8 @@ def __init__(self): self.favicon = None self.trackingVectorClass = "tracking-vector" self.trackingVectorImage = None - self.trackingVectorTitle = "There is a potential tracking vector here." + self.trackingVectorText = "(This is a tracking vector.) " # The space is to separate from the following text. + self.trackingVectorTitle = "There is a tracking vector here." self.forceCrossorigin = False self.group = None self.h1 = None @@ -1022,6 +1023,7 @@ def parseLiteralList(key, val, lineNum): "TR": Metadata("TR", "TR", joinValue, parseLiteral), "Tracking Vector Class": Metadata("Tracking Vector Class", "trackingVectorClass", joinValue, parseLiteralOrNone), "Tracking Vector Image": Metadata("Tracking Vector Image", "trackingVectorImage", joinValue, parseLiteralOrNone), + "Tracking Vector Text": Metadata("Tracking Vector Text", "trackingVectorText", joinValue, parseLiteral), "Tracking Vector Title": Metadata("Tracking Vector Title", "trackingVectorTitle", joinValue, parseLiteral), "Translate Ids": Metadata("Translate Ids", "translateIDs", joinDdList, parseTranslateIDs), "Translation": Metadata("Translation", "translations", joinList, parseTranslation), diff --git a/tests/fingerprint001.html b/tests/fingerprint001.html index 3833c0ee79..e857e1fa98 100644 --- a/tests/fingerprint001.html +++ b/tests/fingerprint001.html @@ -179,11 +179,11 @@

Table of Contents

Here’s some text.

- - There is a potential tracking vector here. + + There is a tracking vector here. - Some more text that fingerprints! + Some more text that fingerprints!

And then some more after that.

@@ -191,4 +191,4 @@

Table of Contents

- \ No newline at end of file + diff --git a/tests/fingerprint003.bs b/tests/fingerprint003.bs index 23d8ebfe58..038287a4a2 100644 --- a/tests/fingerprint003.bs +++ b/tests/fingerprint003.bs @@ -5,7 +5,7 @@ Shortname: foo Level: 1 Status: LS ED: http://example.com/foo -Abstract: Testing that 'Fingerprint Class: foo' works. +Abstract: Testing that 'Tracking Vector Class: foo' works. Tracking Vector Class: foo Editor: Example Editor Date: 1970-01-01 @@ -13,6 +13,6 @@ Date: 1970-01-01 Here's some text. -

Some text that fingerprints. +

Some text that tracks. And then some more after that. diff --git a/tests/fingerprint003.html b/tests/fingerprint003.html index 96547c183f..4b75b8ab23 100644 --- a/tests/fingerprint003.html +++ b/tests/fingerprint003.html @@ -170,7 +170,7 @@

Abstract

-

Testing that 'Fingerprint Class: foo' works.

+

Testing that 'Tracking Vector Class: foo' works.

Here’s some text.

-

There is a potential tracking vector here.Some text that fingerprints!

+

(This is a tracking vector.) Some text that fingerprints!

And then some more after that.

-
\ No newline at end of file + diff --git a/tests/fingerprint005.html b/tests/fingerprint005.html index e677a96ec5..e31ccfec9d 100644 --- a/tests/fingerprint005.html +++ b/tests/fingerprint005.html @@ -179,11 +179,11 @@

Table of Contents

Here’s some text.

- + There is a potential tracking vector here. - Some text that fingerprints! + Some text that fingerprints!

And then some more after that.

@@ -191,4 +191,4 @@

Table of Contents

- \ No newline at end of file + diff --git a/tests/fingerprint006.html b/tests/fingerprint006.html index 2171d46ffb..75db1e726f 100644 --- a/tests/fingerprint006.html +++ b/tests/fingerprint006.html @@ -179,11 +179,11 @@

Table of Contents

Here’s some text.

- + A custom Tracking Vector title, <script>alert("xss")</script>. - Some text that fingerprints! + Some text that fingerprints!

And then some more after that.

@@ -191,4 +191,4 @@

Table of Contents

- \ No newline at end of file +