lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
阅读:2463回复:4

关于本论坛代码语法高亮功能

楼主#
更多 发布于:2018-04-29 20:21
除IE 和 Edge 外, Firefox 和 Chrome 浏览本论坛的代码语法高亮都不正常。
Firefox 的 webconsole 中提示
TypeError: RegExp exec method should return object or null shCore.js:94:41

Chrome 的
Uncaught TypeError: RegExp exec method returned something other than an Object or null


两个浏览器都指向
https://www.firefox.net.cn/res/js/dev/windeditor/plugins/insertCode/syntaxHihglighter/scripts/shCore.js?v=20140228
脚本的一个错误。

我尝试将本含有代码高亮的页面“另存为”,
并将 shCore.js 脚本中
的290行
if(!str) { return; }
改为
if(!str) { return null; }
结果在本地能成功地修复这个问题。

希望管理员试试这个方法,看能否修复。@fiag

Test:
--- .\shCore.js 2018-04-29 19:32:55.000000000 +0800
+++ .\shCore.js 2018-04-29 19:40:01.000000000 +0800
@@ -284,13 +284,13 @@
     // Adds named capture support (with backreferences returned as `result.name`), and fixes two
     // cross-browser issues per ES3:
     // - Captured values for nonparticipating capturing groups should be returned as `undefined`,
     //   rather than the empty string.
     // - `lastIndex` should not be incremented after zero-length matches.
     RegExp.prototype.exec = function (str) {
-        if(!str) { return; }
+        if(!str) { return null; }
         var match = real.exec.apply(this, arguments),
             name, r2;
         if (match) {
             // Fix browsers whose `exec` methods don't consistently return `undefined` for
             // nonparticipating capturing groups
             if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
fiag
管理员
管理员
  • UID1188
  • 注册日期2004-12-21
  • 最后登录2024-02-19
  • 发帖数4681
  • 经验686枚
  • 威望0点
  • 贡献值402点
  • 好评度51点
1楼#
发布于:2018-05-05 08:11
lonely_8:哈,看起来修复了。回到原帖
论坛代码太旧了,手动捂脸
lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
2楼#
发布于:2018-05-03 00:50
fiag:diff 已合并。回到原帖
哈,看起来修复了。
fiag
管理员
管理员
  • UID1188
  • 注册日期2004-12-21
  • 最后登录2024-02-19
  • 发帖数4681
  • 经验686枚
  • 威望0点
  • 贡献值402点
  • 好评度51点
3楼#
发布于:2018-05-02 22:59
diff 已合并。
lonely_8
非常火狐
非常火狐
  • UID30273
  • 注册日期2009-09-03
  • 最后登录2022-08-09
  • 发帖数733
  • 经验469枚
  • 威望0点
  • 贡献值86点
  • 好评度147点
  • 社区居民
  • 忠实会员
4楼#
发布于:2018-04-29 20:30
游客

返回顶部