-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Branch: refs/heads/master Date: 2016-10-11T22:26:01+02:00 Author: Huub Bouma (huubbouma) <[email protected]> Commit: plone/diazo@2e2fcaa only add absolute prefix for xlink:href attributes if url doesn't start with a '#' (use anchor_safe_urljoin) Files changed: M CHANGES.rst M lib/diazo/rules.py M lib/diazo/tests/absolute-prefix/output.html M lib/diazo/tests/absolute-prefix/theme.html Repository: diazo Branch: refs/heads/master Date: 2016-10-11T14:51:41-07:00 Author: Laurence Rowe (lrowe) <[email protected]> Commit: plone/diazo@5dbf906 Merge pull request #63 from huubbouma/master use anchor_safe_urljoin for xlink:href attributes Files changed: M CHANGES.rst M lib/diazo/rules.py M lib/diazo/tests/absolute-prefix/output.html M lib/diazo/tests/absolute-prefix/theme.html
- Loading branch information
Showing
1 changed file
with
163 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,120 +2,186 @@ Repository: diazo | |
|
||
|
||
Branch: refs/heads/master | ||
Date: 2016-10-11T12:46:05-07:00 | ||
Author: Laurence Rowe (lrowe) <lrowe@netflix.com> | ||
Commit: https://github.com/plone/diazo/commit/e77c4b598b9c1ce09bd0c317eff0279c16791b67 | ||
Date: 2016-10-11T22:26:01+02:00 | ||
Author: Huub Bouma (huubbouma) <bouma@w20e.com> | ||
Commit: https://github.com/plone/diazo/commit/2e2fcaabca2590bcb048d9a6965de2bd6e01ee64 | ||
|
||
Fix flake8 install on travis. | ||
only add absolute prefix for xlink:href attributes | ||
if url doesn't start with a '#' (use anchor_safe_urljoin) | ||
|
||
Files changed: | ||
M .travis.yml | ||
|
||
diff --git a/.travis.yml b/.travis.yml | ||
index a19920a..9be4611 100644 | ||
--- a/.travis.yml | ||
+++ b/.travis.yml | ||
@@ -5,7 +5,7 @@ python: | ||
- 3.3 | ||
- 3.4 | ||
install: | ||
- - pip install --use-mirrors flake8 | ||
+ - pip install flake8 | ||
script: | ||
- flake8 lib setup.py | ||
- python setup.py test | ||
|
||
|
||
Repository: diazo | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2016-10-11T12:53:06-07:00 | ||
Author: Laurence Rowe (lrowe) <[email protected]> | ||
Commit: https://github.com/plone/diazo/commit/ad8fca54faf47eeb3c8383506254552f7fbb4b3f | ||
|
||
Stop testing against Python 2.6 as flake8 no longer works there. Add Python 3.5. | ||
|
||
Files changed: | ||
M .travis.yml | ||
M tox.ini | ||
|
||
diff --git a/.travis.yml b/.travis.yml | ||
index 9be4611..a22a884 100644 | ||
--- a/.travis.yml | ||
+++ b/.travis.yml | ||
@@ -1,9 +1,9 @@ | ||
language: python | ||
python: | ||
- - 2.6 | ||
- 2.7 | ||
- 3.3 | ||
- 3.4 | ||
+ - 3.5 | ||
install: | ||
- pip install flake8 | ||
script: | ||
diff --git a/tox.ini b/tox.ini | ||
index 06b54c2..b52d3ab 100644 | ||
--- a/tox.ini | ||
+++ b/tox.ini | ||
@@ -4,7 +4,7 @@ | ||
# and then run "tox" from this directory. | ||
M CHANGES.rst | ||
M lib/diazo/rules.py | ||
M lib/diazo/tests/absolute-prefix/output.html | ||
M lib/diazo/tests/absolute-prefix/theme.html | ||
|
||
diff --git a/CHANGES.rst b/CHANGES.rst | ||
index 941e9c3..89364d8 100644 | ||
--- a/CHANGES.rst | ||
+++ b/CHANGES.rst | ||
@@ -12,6 +12,10 @@ New features: | ||
|
||
[tox] | ||
-envlist = flake8, py26, py27, py33, py34 | ||
+envlist = flake8, py27, py33, py34, py35 | ||
- *add item here* | ||
|
||
[testenv] | ||
commands = python setup.py test | ||
+- only add absolute prefix for xlink:href attributes if url doesn't start | ||
+ with a '#' (use anchor_safe_urljoin) | ||
+ [huubbouma] | ||
+ | ||
Bug fixes: | ||
|
||
- *add item here* | ||
diff --git a/lib/diazo/rules.py b/lib/diazo/rules.py | ||
index 59e6473..53a1ea9 100644 | ||
--- a/lib/diazo/rules.py | ||
+++ b/lib/diazo/rules.py | ||
@@ -142,7 +142,7 @@ def apply_absolute_prefix(theme_doc, absolute_prefix): | ||
node.set('src', url) | ||
for xlink_attr in theme_doc.xpath('//@*[local-name()="xlink:href"]'): | ||
node = xlink_attr.getparent() | ||
- url = urljoin(absolute_prefix, node.get('xlink:href')) | ||
+ url = anchor_safe_urljoin(absolute_prefix, node.get('xlink:href')) | ||
node.set('xlink:href', url) | ||
for node in theme_doc.xpath('//*[@srcset]'): | ||
srcset = node.get('srcset') | ||
diff --git a/lib/diazo/tests/absolute-prefix/output.html b/lib/diazo/tests/absolute-prefix/output.html | ||
index a2c2c78..58b07e7 100644 | ||
--- a/lib/diazo/tests/absolute-prefix/output.html | ||
+++ b/lib/diazo/tests/absolute-prefix/output.html | ||
@@ -39,9 +39,18 @@ | ||
<input type="submit" src="http://site.com/foo.jpg" /> | ||
<a href="/abs/foo.html">Link</a> | ||
<a href="#foo">Anchor</a> | ||
+ <svg> | ||
+ <symbol id="symbol666"> | ||
+ <circle cx="20" cy="20" r="20" stroke-width="5" stroke="red" fill="red"> | ||
+ </circle> | ||
+ </symbol> | ||
+ </svg> | ||
<div xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<svg><use xlink:href="/abs/img/foo.svg"></use></svg> | ||
<span xlink:href="/abs/foo.html"></span> | ||
+ <svg> | ||
+ <use xlink:href="#symbol666" x="0" y="0" width="100" height="50"></use> | ||
+ </svg> | ||
</div> | ||
</body> | ||
</html> | ||
diff --git a/lib/diazo/tests/absolute-prefix/theme.html b/lib/diazo/tests/absolute-prefix/theme.html | ||
index 94cd30b..7a4763d 100644 | ||
--- a/lib/diazo/tests/absolute-prefix/theme.html | ||
+++ b/lib/diazo/tests/absolute-prefix/theme.html | ||
@@ -39,9 +39,18 @@ | ||
<input type="submit" src="http://site.com/foo.jpg" /> | ||
<a href="foo.html">Link</a> | ||
<a href="#foo">Anchor</a> | ||
+ <svg> | ||
+ <symbol id="symbol666"> | ||
+ <circle cx="20" cy="20" r="20" stroke-width="5" stroke="red" fill="red"> | ||
+ </circle> | ||
+ </symbol> | ||
+ </svg> | ||
<div xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<svg><use xlink:href="img/foo.svg"></use></svg> | ||
<span xlink:href="foo.html"></span> | ||
+ <svg> | ||
+ <use xlink:href="#symbol666" x="0" y="0" width="100" height="50"></use> | ||
+ </svg> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
|
||
Repository: diazo | ||
|
||
|
||
Branch: refs/heads/master | ||
Date: 2016-10-11T12:57:31-07:00 | ||
Date: 2016-10-11T14:51:41-07:00 | ||
Author: Laurence Rowe (lrowe) <[email protected]> | ||
Commit: https://github.com/plone/diazo/commit/58d27efae028306aa783b2a231009cde441983e9 | ||
Commit: https://github.com/plone/diazo/commit/5dbf906f2bc53d880bb7628fc3e3a991ae57705e | ||
|
||
Merge pull request #64 from plone/fix-travis-flake8-install | ||
Merge pull request #63 from huubbouma/master | ||
|
||
Fix travis flake8 install | ||
use anchor_safe_urljoin for xlink:href attributes | ||
|
||
Files changed: | ||
M .travis.yml | ||
M tox.ini | ||
|
||
diff --git a/.travis.yml b/.travis.yml | ||
index a19920a..a22a884 100644 | ||
--- a/.travis.yml | ||
+++ b/.travis.yml | ||
@@ -1,11 +1,11 @@ | ||
language: python | ||
python: | ||
- - 2.6 | ||
- 2.7 | ||
- 3.3 | ||
- 3.4 | ||
+ - 3.5 | ||
install: | ||
- - pip install --use-mirrors flake8 | ||
+ - pip install flake8 | ||
script: | ||
- flake8 lib setup.py | ||
- python setup.py test | ||
diff --git a/tox.ini b/tox.ini | ||
index 06b54c2..b52d3ab 100644 | ||
--- a/tox.ini | ||
+++ b/tox.ini | ||
@@ -4,7 +4,7 @@ | ||
# and then run "tox" from this directory. | ||
M CHANGES.rst | ||
M lib/diazo/rules.py | ||
M lib/diazo/tests/absolute-prefix/output.html | ||
M lib/diazo/tests/absolute-prefix/theme.html | ||
|
||
diff --git a/CHANGES.rst b/CHANGES.rst | ||
index 941e9c3..89364d8 100644 | ||
--- a/CHANGES.rst | ||
+++ b/CHANGES.rst | ||
@@ -12,6 +12,10 @@ New features: | ||
|
||
- *add item here* | ||
|
||
[tox] | ||
-envlist = flake8, py26, py27, py33, py34 | ||
+envlist = flake8, py27, py33, py34, py35 | ||
+- only add absolute prefix for xlink:href attributes if url doesn't start | ||
+ with a '#' (use anchor_safe_urljoin) | ||
+ [huubbouma] | ||
+ | ||
Bug fixes: | ||
|
||
[testenv] | ||
commands = python setup.py test | ||
- *add item here* | ||
diff --git a/lib/diazo/rules.py b/lib/diazo/rules.py | ||
index 59e6473..53a1ea9 100644 | ||
--- a/lib/diazo/rules.py | ||
+++ b/lib/diazo/rules.py | ||
@@ -142,7 +142,7 @@ def apply_absolute_prefix(theme_doc, absolute_prefix): | ||
node.set('src', url) | ||
for xlink_attr in theme_doc.xpath('//@*[local-name()="xlink:href"]'): | ||
node = xlink_attr.getparent() | ||
- url = urljoin(absolute_prefix, node.get('xlink:href')) | ||
+ url = anchor_safe_urljoin(absolute_prefix, node.get('xlink:href')) | ||
node.set('xlink:href', url) | ||
for node in theme_doc.xpath('//*[@srcset]'): | ||
srcset = node.get('srcset') | ||
diff --git a/lib/diazo/tests/absolute-prefix/output.html b/lib/diazo/tests/absolute-prefix/output.html | ||
index a2c2c78..58b07e7 100644 | ||
--- a/lib/diazo/tests/absolute-prefix/output.html | ||
+++ b/lib/diazo/tests/absolute-prefix/output.html | ||
@@ -39,9 +39,18 @@ | ||
<input type="submit" src="http://site.com/foo.jpg" /> | ||
<a href="/abs/foo.html">Link</a> | ||
<a href="#foo">Anchor</a> | ||
+ <svg> | ||
+ <symbol id="symbol666"> | ||
+ <circle cx="20" cy="20" r="20" stroke-width="5" stroke="red" fill="red"> | ||
+ </circle> | ||
+ </symbol> | ||
+ </svg> | ||
<div xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<svg><use xlink:href="/abs/img/foo.svg"></use></svg> | ||
<span xlink:href="/abs/foo.html"></span> | ||
+ <svg> | ||
+ <use xlink:href="#symbol666" x="0" y="0" width="100" height="50"></use> | ||
+ </svg> | ||
</div> | ||
</body> | ||
</html> | ||
diff --git a/lib/diazo/tests/absolute-prefix/theme.html b/lib/diazo/tests/absolute-prefix/theme.html | ||
index 94cd30b..7a4763d 100644 | ||
--- a/lib/diazo/tests/absolute-prefix/theme.html | ||
+++ b/lib/diazo/tests/absolute-prefix/theme.html | ||
@@ -39,9 +39,18 @@ | ||
<input type="submit" src="http://site.com/foo.jpg" /> | ||
<a href="foo.html">Link</a> | ||
<a href="#foo">Anchor</a> | ||
+ <svg> | ||
+ <symbol id="symbol666"> | ||
+ <circle cx="20" cy="20" r="20" stroke-width="5" stroke="red" fill="red"> | ||
+ </circle> | ||
+ </symbol> | ||
+ </svg> | ||
<div xmlns:xlink="http://www.w3.org/1999/xlink"> | ||
<svg><use xlink:href="img/foo.svg"></use></svg> | ||
<span xlink:href="foo.html"></span> | ||
+ <svg> | ||
+ <use xlink:href="#symbol666" x="0" y="0" width="100" height="50"></use> | ||
+ </svg> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
|