OpenComic icon indicating copy to clipboard operation
OpenComic copied to clipboard

(Windows) Breadcrumb bug for .cbz whose parent folder name contains square brackets

Open mchubby opened this issue 2 years ago • 2 comments

Steps to reproduce

  • mkdir C:[folder]

  • place .cbz into that folder

  • double-click open the archive

  • click on the folder name in the bar image

Expected Result

Browsing folder contents

Observed Result

Uncaught exception message box

image

Linenumber 273:5

Error: Uncaught Error: ENOENT: no such file or directory, stat 'C:\[folder]\C:\[folder]' at linenumber 273:5 of file internal/fs/utils.js

Error: ENOENT: no such file or directory, stat 'C:\[folder]\C:\[folder]'
    at statSync (fs.js:1020:3)
    at Object.e.statSync (electron/js2c/asar_bundle.js:5:4264)
    at Object.loadIndexPage ((...)\OpenComic\resources\app.asar\scripts\dom.js:490:11)
    at HTMLSpanElement.onclick (file:///C:/(...)/OpenComic/resources/app.asar/templates/index.html:1:5)

Using the debug feature:

Node contents:

<div class="bar-title" style="max-width: calc(100% - (184px + 68px));">
			<span class="bar-title-a" onclick="dom.loadIndexPage(true, 'C:\\[folder]\\C:', false, false, 'C:\\[folder]\\Chapter 001.cbz')">C:</span>
			 <i class="material-icon navegation">chevron_right</i> 
			<span class="bar-title-a" onclick="dom.loadIndexPage(true, 'C:\\[folder]\\C:\\[folder]', false, false, 'C:\\[folder]\\Chapter 001.cbz')">[folder]</span>
			 <i class="material-icon navegation">chevron_right</i> 
			<span class="bar-title-a" onclick="dom.loadIndexPage(true, 'C:\\[folder]\\C:\\[folder]\\Chapter 001.cbz', false, false, 'C:\\[folder]\\Chapter 001.cbz')">Chapter 001.cbz</span>
			
</div>

loadIndexPage call

  • path == "C:[folder]\C:[folder]"
  • mainPath == "C:[folder]\Chapter 001.cbz"

What happens when opening the cbz file initially?

https://github.com/ollm/OpenComic/blob/48412c57c73762cbf089c0e5dbe7a02dd0292bee/scripts/dom.js#L1061-L1068

Evaluate {file: files[index], path: p.join(mainPathR, prev, files[index]), mainPath: mainPath} index == 0: {file: "C:", path: "C:\[folder]\C:", mainPath: "C:\[folder]\Chapter 001.cbz"} index == 1: {file: "[folder]", path: "C:\[folder]\C:.\[folder]", mainPath: "C:\[folder]\Chapter 001.cbz"} index == 2: {file: "Chapter 001.cbz", path: "C:\[folder]\C:[folder]\Chapter 001.cbz", mainPath: "C:\[folder]\Chapter 001.cbz"}

mchubby avatar May 25 '22 21:05 mchubby

One reason may be because escapeBackSlash does not handle all special characters for use in new RegExp, e.g. character ranges.

mchubby avatar May 25 '22 22:05 mchubby

Fixed in 5499e39a3a026b636cdf9bf907d47ba3d4f5ca64

As you said, regular expressions were not properly escaped.

I leave you a version with the fix applied so you can test it and confirm that the bug is fixed.

https://mega.nz/file/nDwSWbIa#2ixhHR7pS4V1V6kNkBXrUpzCkLGM5UYsEDiplU4Cf_w

ollm avatar Jun 17 '22 14:06 ollm

Closed as probably fixed in v1.0.0-beta.2

ollm avatar Sep 05 '23 18:09 ollm