You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2023/01/04 22:11:48 UTC
[allura] branch master updated: [#8483] restore unlimited image/link bracket sizes in markdown; fix indentation in test case input
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git
The following commit(s) were added to refs/heads/master by this push:
new 9bf0f353f [#8483] restore unlimited image/link bracket sizes in markdown; fix indentation in test case input
9bf0f353f is described below
commit 9bf0f353f3fc0c563cbabee82cdae10444d1af3f
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Wed Jan 4 17:04:51 2023 -0500
[#8483] restore unlimited image/link bracket sizes in markdown; fix indentation in test case input
---
Allura/allura/lib/markdown_extensions.py | 2 +-
Allura/allura/tests/test_globals.py | 43 +++-----------------------------
2 files changed, 5 insertions(+), 40 deletions(-)
diff --git a/Allura/allura/lib/markdown_extensions.py b/Allura/allura/lib/markdown_extensions.py
index c1d089d77..e69ab1c68 100644
--- a/Allura/allura/lib/markdown_extensions.py
+++ b/Allura/allura/lib/markdown_extensions.py
@@ -47,7 +47,7 @@ SHORT_REF_RE = markdown.inlinepatterns.NOIMG + r'\[([^\]]+)\]'
# FORGE_LINK_RE copied from markdown pre 3.0's LINK_RE
# TODO: replace these with newer approach, see ForgeLinkPattern
-NOBRACKET = r'[^\]\[]{0,100}' # "*" changed to {0,100} for performance mitigation
+NOBRACKET = r'[^\]\[]*' # if not using regex-as-re-globally, must change "*" to {0,50} for performance mitigation
BRK = (
r'\[(' +
(NOBRACKET + r'(\[')*6 +
diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py
index 2ed823368..b0e4d56af 100644
--- a/Allura/allura/tests/test_globals.py
+++ b/Allura/allura/tests/test_globals.py
@@ -14,8 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
-
+import inspect
import re
import os
from textwrap import dedent
@@ -587,7 +586,8 @@ class Test():
'rel="nofollow">xss</a></p></div>' == r)
def test_markdown_extremely_slow(self):
- r = g.markdown.convert('''bonjour, voila ce que j'obtient en voulant ajouter un utilisateur a un groupe de sécurite, que ce soit sur un groupe pre-existant, ou sur un groupe crée.
+ # regex-as-re-globally package mitigates this being slow; also see `NOBRACKET` comments
+ g.markdown.convert(inspect.cleandoc('''bonjour, voila ce que j'obtient en voulant ajouter un utilisateur a un groupe de sécurite, que ce soit sur un groupe pre-existant, ou sur un groupe crée.
message d'erreur:
ERROR: Could not complete the Add UserLogin To SecurityGroup [file:/C:/neogia/ofbizNeogia/applications/securityext/script/org/ofbiz/securityext/securitygroup/SecurityGroupServices.xml#addUserLoginToSecurityGroup] process [problem creating the newEntity value: Exception while inserting the following entity: [GenericEntity:UserLoginSecurityGroup][createdStamp,2006-01-23 17:42:39.312(java.sql.Timestamp)][createdTxStamp,2006-01-23 17:42:38.875(java.sql.Timestamp)][fromDate,2006-01-23 17: [...]
@@ -597,44 +597,9 @@ class Test():
Si une idée vous vient à l'esprit, merci de me tenir au courant.
- cordialement, julien.''')
+ cordialement, julien.'''))
assert True # finished!
- @td.with_tool('test', 'Wiki', 'wiki-len')
- def test_markdown_link_length_limits(self):
- with h.push_context('test', 'wiki-len', neighborhood='Projects'):
- # these are always ok, no matter the NOBRACKET length
- WM.Page.upsert(title='12345678901').commit()
- text = g.markdown.convert('See [12345678901]')
- assert 'href="/p/test/wiki-len/12345678901/">[12345678901]</a>' in text, text
- WM.Page.upsert(title='this is 26 characters long').commit()
- text = g.markdown.convert('See [this is 26 characters long]')
- assert 'href="/p/test/wiki-len/this%20is%2026%20characters%20long/">[this is 26 characters long]</a>' in text, text
-
- # NOBRACKET regex length impacts standard markdown links
- text = g.markdown.convert('See [short](http://a.de)')
- assert 'href="http://a.de" rel="nofollow">short</a>' in text, text
- text = g.markdown.convert('See [this is 26 characters long](http://a.de)')
- assert 'href="http://a.de" rel="nofollow">this is 26 characters long</a>' in text, text # {0,12} fails {0,13} ok
-
- # NOBRACKET regex length impacts our custom artifact links
- text = g.markdown.convert('See [short](Home)')
- assert 'href="/p/test/wiki-len/Home/">short</a>' in text, text
- text = g.markdown.convert('See [123456789](Home)')
- assert 'href="/p/test/wiki-len/Home/">123456789</a>' in text, text
- text = g.markdown.convert('See [12345678901](Home)')
- assert 'href="/p/test/wiki-len/Home/">12345678901</a>' in text, text # {0,5} fails, {0,6} ok
- text = g.markdown.convert('See [this is 16 chars](Home)')
- assert 'href="/p/test/wiki-len/Home/">this is 16 chars</a>' in text, text # {0,7} fails {0,8} ok
- text = g.markdown.convert('See [this is 26 characters long](Home)')
- assert 'href="/p/test/wiki-len/Home/">this is 26 characters long</a>' in text, text # {0,12} fails {0,13} ok
-
- # limit, currently
- charSuperLong = '1234567890'*21
- text = g.markdown.convert(f'See [{charSuperLong}](Home)')
- assert f'<span>[{charSuperLong}]</span>(Home)' in text, text # current limitation, not a link
- # assert f'href="/p/test/wiki-len/Home/">{charSuperLong}</a>' in text, text # ideal output
-
def test_macro_include(self):
r = g.markdown.convert('[[include ref=Home id=foo]]')
assert '<div id="foo">' in r, r