Skip to content

isValidRev(): reject revs with more than one dash#8933

Merged
SourceR85 merged 1 commit intoapache:masterfrom
alxndrsn:stricter-revs
Apr 15, 2024
Merged

isValidRev(): reject revs with more than one dash#8933
SourceR85 merged 1 commit intoapache:masterfrom
alxndrsn:stricter-revs

Conversation

@alxndrsn
Copy link
Copy Markdown
Contributor

@alxndrsn alxndrsn commented Apr 13, 2024

There are various places in the code where revs are assumed to include a single dash character:

* pouchdb-adapter-idb/src/index.js:533: doc._rev = '0-' + (parseInt(oldRev.split('-')[1], 10) + 1);
* pouchdb-adapter-leveldb-core/src/index.js:1402: oldRev ? '0-' + (parseInt(oldRev.split('-')[1], 10) + 1) : '0-1';
* pouchdb-core/src/adapter.js:249: var parts = doc._rev.split('-');
* pouchdb-core/src/adapter.js:599: var splittedRev = doc._rev.split('-');
* pouchdb-core/src/adapter.js:623: const pathId = doc._rev.split('-')[1];
* pouchdb-merge/src/revExists.js:4: var splitRev = rev.split('-');

Follow-up to #8931

There are various places in the code where revs are assumed to include a single
dash character:

* pouchdb-adapter-idb/src/index.js:533: doc._rev = '0-' + (parseInt(oldRev.split('-')[1], 10) + 1);
* pouchdb-adapter-leveldb-core/src/index.js:1402: oldRev ? '0-' + (parseInt(oldRev.split('-')[1], 10) + 1) : '0-1';
* pouchdb-core/src/adapter.js:249: var parts = doc._rev.split('-');
* pouchdb-core/src/adapter.js:599: var splittedRev = doc._rev.split('-');
* pouchdb-core/src/adapter.js:623: const pathId = doc._rev.split('-')[1];
* pouchdb-merge/src/revExists.js:4: var splitRev = rev.split('-');

Follow-up to apache#8931
@SourceR85
Copy link
Copy Markdown
Contributor

I'm curious: Is "1-" also a valid revision ID for CouchDB?
Or was the original check just a hack?

Copy link
Copy Markdown
Contributor

@SourceR85 SourceR85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's room for improvement of checking the hash (e.g. check for illegal characters),
but that's a story for another PR.

@SourceR85 SourceR85 merged commit 7505bed into apache:master Apr 15, 2024
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