Skip to content

Add length checks to prevent attempting to insert pages after end of document#70

Merged
Azeirah merged 3 commits intoScrybbling-together:mainfrom
avncharlie:prevent-over-inserting
Mar 1, 2026
Merged

Add length checks to prevent attempting to insert pages after end of document#70
Azeirah merged 3 commits intoScrybbling-together:mainfrom
avncharlie:prevent-over-inserting

Conversation

@avncharlie
Copy link

I have a strange notebook (originally ePub), that causes remarks to crash while trying to process it. Specifically it falls over at this line:

pdf_src.fullcopy_page(pno=page_idx)

As it tries to insert a page far after the source pdf has ended. I am unsure why the underlying notebook is like this - maybe something when wrong in Remarkable's ePub to pdf conversion?

I added a small fix here that makes sure that new pages are only added at the end of the pdf, this seems to fix it.

As it the notebook causing this issue is a purchased ePub I'm hesitant to share it publicly but happy to DM it to you for testing if you require.

@avncharlie avncharlie force-pushed the prevent-over-inserting branch from 69d4287 to 0703bf8 Compare January 25, 2026 05:18
@avncharlie
Copy link
Author

Also added a fix for supporting a deleted inserted page
i.e when you add a page (using the insert page functionality) into a pdf/ebook and then you delete it, remarks currently attempts to still add it to the output pdf.

@avncharlie
Copy link
Author

Added a fix for weird edge case where an rm file exists on disk, but is not part of the 'pages' list in xochitl <uuid>.content file. As list_ann_rm_files indexes every rm file on disk, and but attempt to look up rm files it finds in self.pages_list which is built from the pages list in the <uuid>.content file, remarks crashes if there's an rm file that isn't in the .content pages list.

@Azeirah
Copy link
Collaborator

Azeirah commented Feb 23, 2026

Added a fix for weird edge case where an rm file exists on disk, but is not part of the 'pages' list in xochitl <uuid>.content file. As list_ann_rm_files indexes every rm file on disk, and but attempt to look up rm files it finds in self.pages_list which is built from the pages list in the <uuid>.content file, remarks crashes if there's an rm file that isn't in the .content pages list.

Is the file that causes this error something you can add to tests? Given the wide scope of strange issues with PDFs and edge cases with .rm files I am very strict on testing. Every change in remarks should be accompanied by a test file or test case.

@avncharlie avncharlie force-pushed the prevent-over-inserting branch from b3108c1 to 1c9dbe8 Compare February 24, 2026 11:15
@avncharlie
Copy link
Author

Added a test. I'm using remarks in a kind of weird way (as a library in my own syncing solution), so I may be running into issues that won't happen in normal usage of remarks.

@Azeirah
Copy link
Collaborator

Azeirah commented Mar 1, 2026

Added a test. I'm using remarks in a kind of weird way (as a library in my own syncing solution), so I may be running into issues that won't happen in normal usage of remarks.

I don't know what "normal" usage of remarks means to be honest, it's meant to be a reliable tool and library to process .rmdoc files. That's about it.

@Azeirah
Copy link
Collaborator

Azeirah commented Mar 1, 2026

It looks all good, want to merge it but one tiny thing is that the test file's name overlaps with another test file's name so output.

You can open the zip and edit the file metadata's visibleName object to change its name. Ready to merge otherwise (don't forget to update the filename in the test fixture too!)

@avncharlie avncharlie force-pushed the prevent-over-inserting branch from 1c9dbe8 to 253a807 Compare March 1, 2026 21:41
@Azeirah
Copy link
Collaborator

Azeirah commented Mar 1, 2026

The force push includes #16. If it's just the name, then it's ready to merge.

@avncharlie avncharlie force-pushed the prevent-over-inserting branch from 253a807 to c804670 Compare March 1, 2026 21:48
@avncharlie
Copy link
Author

Oops, fixed now. this branch should just have the relevant commits rebased on top of main now.

@Azeirah
Copy link
Collaborator

Azeirah commented Mar 1, 2026

I added CI to remarks by the way! Should have done this like 2 years ago 😅

image

@Azeirah Azeirah merged commit e228600 into Scrybbling-together:main Mar 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants