[gtksourceview/gnome-3-24] yaml: simplify map regex



commit 9b845395d46e9c49a0c4cdafc76fe87d07d67594
Author: Christian Hergert <chergert redhat com>
Date:   Fri Apr 19 14:58:31 2019 -0700

    yaml: simplify map regex
    
    This reduces the complexity of the map check a bit and still matches the
    majority of cases that I tried.
    
    Fixes #47

 data/language-specs/yaml.lang | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/data/language-specs/yaml.lang b/data/language-specs/yaml.lang
index 99db2cae..7aca3c99 100644
--- a/data/language-specs/yaml.lang
+++ b/data/language-specs/yaml.lang
@@ -167,8 +167,22 @@
       </include>
     </context>
 
+
     <context id="map">
+      <!--
+        The following can cause a stack-overflow in libpcre if the map entry
+        contains lots of HTTP urls. If you have a better design for this, please
+        contribute an improvement. Another option might be for GRegex to be
+        compiled without recurse support, but that doesn't fix things that
+        are out in the wild already.
+
+        To generate the failure case try:
+
+        python3 -c 'print("key:", "http://example.com " * 1000)' > testcase.yml
+
       <match>(?&lt;=^|\s)((?:[^:]|:(?=\S))+)(?::\s+|:$)</match>
+      -->
+      <match>(?&lt;=^|\s)((?:[^:])+)(?::\s+|:$)</match>
       <include>
         <context sub-pattern="1" style-ref="map-key"/>
       </include>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]