Processed: Re: Bug#1000112: kjs: depends on obsolete pcre3 library

2023-12-23 Thread Debian Bug Tracking System
Processing control commands:

> tags -1 + patch
Bug #1000112 [src:kjs] kjs: depends on obsolete pcre3 library
Bug #1000115 [src:kjs] kjs: depends on obsolete pcre3 library
Added tag(s) patch.
Added tag(s) patch.

-- 
1000112: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000112
1000115: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1000115
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#1000112: kjs: depends on obsolete pcre3 library

2023-12-23 Thread Yavor Doganov
Control: tags -1 + patch

Please find attached a patch; build-tested only.

I was unsure what to do with the recursion limit code in the match
method.  In the old PCRE3, PCRE_CONFIG_STACKRECURSE is 1 because of
the recursion implementation, which is stack-based.  In PCRE2, the
corresponding parameter PCRE2_CONFIG_STACKRECURSE is obsolete and
always 0.

Furthermore, according to pcre2api(3), if the recursion is great
enough, workspace vectors are allocated on the heap from version 10.32
onwards.  It also says that only local variables are allocated on the
stack and even a small stack can support a lot of recursion.  So I
concluded that limiting the stack space is unnecessary with PCRE2.  I
guess that only runtime tests can show if this is true, but as I am
not a Qt/KDE person I am unable to perform them, I'm afraid.

In any case, it is trivial to limit both the stack and the heap via a
match context -- just let me know and I'll make the required
modifications.

P.S.  This patch applies cleanly to the latest upstream release
  (5.113.0) but I haven't made a build test with it.
Description: Port to PCRE2.
Bug-Debian: https://bugs.debian.org/1000112
Bug: https://bugs.kde.org/show_bug.cgi?id=457338
Author: Yavor Doganov 
Forwarded: no
Last-Update: 2023-12-23
---

--- kjs-5.107.0.orig/cmake/FindPCRE.cmake
+++ kjs-5.107.0/cmake/FindPCRE.cmake
@@ -11,10 +11,10 @@
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
 
-if (PCRE_INCLUDE_DIR AND PCRE_PCREPOSIX_LIBRARY AND PCRE_PCRE_LIBRARY)
+if (PCRE_INCLUDE_DIR AND PCRE_PCRE_LIBRARY)
   # Already in cache, be silent
   set(PCRE_FIND_QUIETLY TRUE)
-endif (PCRE_INCLUDE_DIR AND PCRE_PCREPOSIX_LIBRARY AND PCRE_PCRE_LIBRARY)
+endif (PCRE_INCLUDE_DIR AND PCRE_PCRE_LIBRARY)
 
 
 if (NOT WIN32)
@@ -22,23 +22,21 @@
   # in the FIND_PATH() and FIND_LIBRARY() calls
   find_package(PkgConfig)
 
-  pkg_check_modules(PC_PCRE QUIET libpcre)
+  pkg_check_modules(PC_PCRE QUIET libpcre2-8)
 
   set(PCRE_DEFINITIONS ${PC_PCRE_CFLAGS_OTHER})
 
 endif (NOT WIN32)
 
-find_path(PCRE_INCLUDE_DIR pcre.h 
+find_path(PCRE_INCLUDE_DIR pcre2.h
   HINTS ${PC_PCRE_INCLUDEDIR} ${PC_PCRE_INCLUDE_DIRS} 
-  PATH_SUFFIXES pcre)
+  )
 
-find_library(PCRE_PCRE_LIBRARY NAMES pcre pcred HINTS ${PC_PCRE_LIBDIR} 
${PC_PCRE_LIBRARY_DIRS})
-
-find_library(PCRE_PCREPOSIX_LIBRARY NAMES pcreposix pcreposixd HINTS 
${PC_PCRE_LIBDIR} ${PC_PCRE_LIBRARY_DIRS})
+find_library(PCRE_PCRE_LIBRARY NAMES pcre2-8 HINTS ${PC_PCRE_LIBDIR} 
${PC_PCRE_LIBRARY_DIRS})
 
 include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR 
PCRE_PCRE_LIBRARY PCRE_PCREPOSIX_LIBRARY )
+find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_INCLUDE_DIR 
PCRE_PCRE_LIBRARY)
 
-set(PCRE_LIBRARIES ${PCRE_PCRE_LIBRARY} ${PCRE_PCREPOSIX_LIBRARY})
+set(PCRE_LIBRARIES ${PCRE_PCRE_LIBRARY})
 
-mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARIES PCRE_PCREPOSIX_LIBRARY 
PCRE_PCRE_LIBRARY)
+mark_as_advanced(PCRE_INCLUDE_DIR PCRE_LIBRARIES PCRE_PCRE_LIBRARY)
--- kjs-5.107.0.orig/src/kjs/regexp.h
+++ kjs-5.107.0/src/kjs/regexp.h
@@ -26,7 +26,8 @@
 #include "global.h"
 
 #if HAVE_PCREPOSIX
-#include 
+#define PCRE2_CODE_UNIT_WIDTH 8
+#include 
 #else  // POSIX regex - not so good...
 extern "C" { // bug with some libc5 distributions
 #include 
@@ -115,7 +116,7 @@
 #endif
 private:
 #if HAVE_PCREPOSIX
-pcre *_regex;
+pcre2_code *_regex;
 #else
 regex_t _regex;
 #endif
--- kjs-5.107.0.orig/src/kjs/regexp.cpp
+++ kjs-5.107.0/src/kjs/regexp.cpp
@@ -273,8 +273,8 @@
 #if HAVE_PCREPOSIX
 // Determine whether libpcre has unicode support if need be..
 if (utf8Support == Unknown) {
-int supported;
-pcre_config(PCRE_CONFIG_UTF8, (void *)&supported);
+uint32_t supported;
+pcre2_config(PCRE2_CONFIG_UNICODE, &supported);
 utf8Support = supported ? Supported : Unsupported;
 }
 #endif
@@ -282,50 +282,49 @@
 UString intern = sanitizePattern(p);
 
 #if HAVE_PCREPOSIX
-int options = 0;
+uint32_t options = 0;
 
 // we are close but not 100% the same as Perl
-#ifdef PCRE_JAVASCRIPT_COMPAT // introduced in PCRE 7.7
-options |= PCRE_JAVASCRIPT_COMPAT;
-#endif
+options |= (PCRE2_ALT_BSUX | PCRE2_MATCH_UNSET_BACKREF);
 
 // Note: the Global flag is already handled by RegExpProtoFunc::execute.
 // FIXME: That last comment is dubious. Not all RegExps get run through 
RegExpProtoFunc::execute.
 if (flags & IgnoreCase) {
-options |= PCRE_CASELESS;
+options |= PCRE2_CASELESS;
 }
 if (flags & Multiline) {
-options |= PCRE_MULTILINE;
+options |= PCRE2_MULTILINE;
 }
 
 if (utf8Support == Supported) {
-options |= (PCRE_UTF8 | PCRE_NO_UTF8_CHECK);
+options |= (PCRE2_UTF | PCRE2_NO_UTF_CHECK);
 }
 
-const char *errorMessage;
-int errorOffset;
+PCRE2_UCHAR errorMessage[120];
+PCRE2_SIZE errorOffset;
+int errCode;
 bool 

Bug#1000112: kjs: depends on obsolete pcre3 library

2023-12-11 Thread Bastian Germann

okular and khelpcenter make kjs a key package via khtml.
While it is optional in okular, khelpcenter requires khtml.
This is changing with the 24.08.x versions, which will be part of Plasma 6.
When khelpcenter upgrades to a khtml-free version, this should be followed-up.