Unknown Namespace: #2075

Closed
opened 2020-08-01 08:59:18 +00:00 by Beful · 12 comments
Beful commented 2020-08-01 08:59:18 +00:00 (Migrated from github.com)

Uncaught Error: Unknown Namespace:
at Xlsx.js:21598
at of (Xlsx.js:21600)
at hf (Xlsx.js:21973)
at Object.pf [as read] (Xlsx.js:22087)
at XMLHttpRequest.r.onload (Xlsx.js:1828)

image
image

Uncaught Error: Unknown Namespace: at Xlsx.js:21598 at of (Xlsx.js:21600) at hf (Xlsx.js:21973) at Object.pf [as read] (Xlsx.js:22087) at XMLHttpRequest.r.onload (Xlsx.js:1828) ![image](https://user-images.githubusercontent.com/56426292/89098244-4b8c2200-d418-11ea-8622-8f02ff667498.png) ![image](https://user-images.githubusercontent.com/56426292/89098246-52b33000-d418-11ea-91bf-cc0cb70ed9b8.png)
SheetJSDev commented 2020-08-01 19:52:14 +00:00 (Migrated from github.com)

Can you share a sample file? The check is https://github.com/SheetJS/sheetjs/blob/master/bits/30_ctype.js#L220 which may not even be necessary if Excel doesn't require the namespace for [Content_Types].xml

Can you share a sample file? The check is https://github.com/SheetJS/sheetjs/blob/master/bits/30_ctype.js#L220 which may not even be necessary if Excel doesn't require the namespace for `[Content_Types].xml`
Beful commented 2020-08-03 01:04:36 +00:00 (Migrated from github.com)
var nContainer = document.getElementById('container')
var xlsx = new Plus.Xlsx(nContainer)
xlsx.readFile("/200.xlsx");
```javascript var nContainer = document.getElementById('container') var xlsx = new Plus.Xlsx(nContainer) xlsx.readFile("/200.xlsx"); ```
SheetJSDev commented 2020-08-03 01:11:53 +00:00 (Migrated from github.com)

Can you share that 200.xlsx file?

Can you share that 200.xlsx file?
Beful commented 2020-08-03 01:18:10 +00:00 (Migrated from github.com)

可以

可以
Beful commented 2020-08-03 01:23:33 +00:00 (Migrated from github.com)

image

又报这个错

![image](https://user-images.githubusercontent.com/56426292/89137525-f3196980-d56a-11ea-894e-815e01451433.png) 又报这个错
Beful commented 2020-08-03 01:27:38 +00:00 (Migrated from github.com)
[建筑.xlsx](https://github.com/SheetJS/sheetjs/files/5013397/default.xlsx)
SheetJSDev commented 2020-08-03 01:39:41 +00:00 (Migrated from github.com)

谢谢!

Feel free to submit a patch. The change is in bits/22_xmlutils.js:

--- a/bits/22_xmlutils.js
+++ b/bits/22_xmlutils.js
@@ -1,6 +1,6 @@
 var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n';
 var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g;
-var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g;
+var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg;
 
 if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g;
 var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/;

This is a problem with how we are parsing XML tags. There is a CRLF newline sequence within the root tag, just before the closing >:

00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231  <?xml version="1
00000010: 2e30 2220 656e 636f 6469 6e67 3d22 5554  .0" encoding="UT
00000020: 462d 3822 2073 7461 6e64 616c 6f6e 653d  F-8" standalone=
00000030: 2279 6573 223f 3e0d 3c54 7970 6573 2078  "yes"?>.<Types x
00000040: 6d6c 6e73 3d22 6874 7470 3a2f 2f73 6368  mlns="http://sch
00000050: 656d 6173 2e6f 7065 6e78 6d6c 666f 726d  emas.openxmlform
00000060: 6174 732e 6f72 672f 7061 636b 6167 652f  ats.org/package/
00000070: 3230 3036 2f63 6f6e 7465 6e74 2d74 7970  2006/content-typ
00000080: 6573 2220 0d0a 3e0d 3c44 6566 6175 6c74  es" ..>.<Default
                    ::::

The proposed fix changes the RegExp to use the /m flag and changes the penultimate check to match any number of whitespace characters.

谢谢! Feel free to submit a patch. The change is in `bits/22_xmlutils.js`: ```diff --- a/bits/22_xmlutils.js +++ b/bits/22_xmlutils.js @@ -1,6 +1,6 @@ var XML_HEADER = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n'; var attregexg=/([^"\s?>\/]+)\s*=\s*((?:")([^"]*)(?:")|(?:')([^']*)(?:')|([^'">\s]+))/g; -var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/g; +var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg; if(!(XML_HEADER.match(tagregex))) tagregex = /<[^>]*>/g; var nsregex=/<\w*:/, nsregex2 = /<(\/?)\w+:/; ``` This is a problem with how we are parsing XML tags. There is a CRLF newline sequence within the root tag, just before the closing `>`: ``` 00000000: 3c3f 786d 6c20 7665 7273 696f 6e3d 2231 <?xml version="1 00000010: 2e30 2220 656e 636f 6469 6e67 3d22 5554 .0" encoding="UT 00000020: 462d 3822 2073 7461 6e64 616c 6f6e 653d F-8" standalone= 00000030: 2279 6573 223f 3e0d 3c54 7970 6573 2078 "yes"?>.<Types x 00000040: 6d6c 6e73 3d22 6874 7470 3a2f 2f73 6368 mlns="http://sch 00000050: 656d 6173 2e6f 7065 6e78 6d6c 666f 726d emas.openxmlform 00000060: 6174 732e 6f72 672f 7061 636b 6167 652f ats.org/package/ 00000070: 3230 3036 2f63 6f6e 7465 6e74 2d74 7970 2006/content-typ 00000080: 6573 2220 0d0a 3e0d 3c44 6566 6175 6c74 es" ..>.<Default :::: ``` The proposed fix changes the RegExp to use the `/m` flag and changes the penultimate check to match any number of whitespace characters.
Beful commented 2020-08-03 02:51:28 +00:00 (Migrated from github.com)

image

I,m read 虚拟目录 ,请求链接,是不是不支持

![image](https://user-images.githubusercontent.com/56426292/89141407-25c95f00-d577-11ea-9c06-d7ac0366c2c7.png) I,m read 虚拟目录 ,请求链接,是不是不支持
keithpan commented 2020-12-15 04:39:24 +00:00 (Migrated from github.com)

@SheetJSDev
image
the latest version commit is different from the above reply, it's not changes the penultimate check to match any number of whitespace characters. the latest version is invalid.
can you help me?

@SheetJSDev ![image](https://user-images.githubusercontent.com/49436849/102171759-3a791480-3ed2-11eb-8cd6-5b5b69319ada.png) the latest version commit is different from the above reply, it's not changes the penultimate check to match any number of whitespace characters. the latest version is invalid. can you help me?
SheetJSDev commented 2020-12-15 09:16:30 +00:00 (Migrated from github.com)

@keithpan does it work if you change the modifier near the end as follows:

-var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
+var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg;
                                                                                                ^

The caret is marking the modifier that changed. originally it matches up to one whitespace character and the change lets it match any number

@keithpan does it work if you change the modifier near the end as follows: ```diff -var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg; +var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg; ^ ``` The caret is marking the modifier that changed. originally it matches up to one whitespace character and the change lets it match any number
keithpan commented 2020-12-24 01:17:51 +00:00 (Migrated from github.com)

@keithpan does it work if you change the modifier near the end as follows:

-var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg;
+var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg;
                                                                                                ^

The caret is marking the modifier that changed. originally it matches up to one whitespace character and the change lets it match any number

@SheetJSDev
why does the latest version not have this change?

> @keithpan does it work if you change the modifier near the end as follows: > > ```diff > -var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s?[\/\?]?>/mg; > +var tagregex=/<[\/\?]?[a-zA-Z0-9:_-]+(?:\s+[^"\s?>\/]+\s*=\s*(?:"[^"]*"|'[^']*'|[^'">\s=]+))*\s*[\/\?]?>/mg; > ^ > ``` > > The caret is marking the modifier that changed. originally it matches up to one whitespace character and the change lets it match any number @SheetJSDev why does the latest version not have this change?
ansarikhurshid786 commented 2022-03-29 07:09:31 +00:00 (Migrated from github.com)

I am facing same issue when i publish web server. it is working on local server.

I am facing same issue when i publish web server. it is working on local server.
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#2075
No description provided.