-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor bookmark import using a generic Netscape parser #612
Refactor bookmark import using a generic Netscape parser #612
Conversation
35dae13
to
ce3b210
Compare
ce3b210
to
a2516fa
Compare
a6b7fd5
to
3d9e478
Compare
if (empty($post['default_tags'])) { | ||
$defaultTags = array(); | ||
} else { | ||
$defaultTags = preg_split('/[\s,]+/', $post['default_tags']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user input should be escaped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should input sanitizing be (optionally) held by the parser, or be left to client code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be done by the client. The parser shouldn't know if it needs to be escaped or not (ex: let's say that default tags are retrieve through an ORM which returns escaped data).
There is a bug somewhere. I made an import with a similar database, with overwrite and import as private checked. The import ran fine, but my previous private links are now public (and the public ones are private). EDIT: aside from that and my comment, I'm OK the PR. Nice work with the parser BTW! |
Yup, still a bit rough around the edges, I still have to add UTs and do more testing :) |
f00379f
to
a648e28
Compare
/** | ||
* The user-specified tags contain characters to be escaped | ||
*/ | ||
public function testSanitizeDefaultTags() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure for this one; there are various ways of sanitizing inputs & outputs throughout the code. I think the cleanup should be similar to when a new link is added, which corresponds to the following section:
Apart from tag cleanup, there doesn't seem to be a lot of HTML / special char escaping...
Maybe these operations should be handled by LinkDB
to provide a more consistent behaviour?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, and I made a mistake on this. We actually sanitize link fields when the DB is retrieved, not when links are added/edited. See https://github.com/shaarli/Shaarli/blob/master/application/LinkDB.php#L290.
I remember doing that, but that doesn't feel like a good idea now. We might want to change that later, maybe in #445. Anyway, it means that you don't have to worry about link fields sanitization here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, thanks for the clues ;-)
Comments taken into account + test code updated to run with PHP 5.3:
|
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli/netscape-bookmark-parser#15 Modification: - reference the "shaarli" vendor repository on Packagist instead of overriding the upstream package with an SCM repository See https://packagist.org/packages/shaarli/netscape-bookmark-parser Signed-off-by: VirtualTam <[email protected]>
babd7b5
to
efed72f
Compare
Relates to shaarli#607 Relates to shaarli#608 Relates to shaarli#493 (abandoned) Additions: - use Composer's autoload to load 3rd-party dependencies under vendor/ Modifications: - [import] replace the current parser with a generic, stable parser - move code to application/NetscapeBookmarkUtils - improve status report after parsing - [router] use the same endpoint for both bookmark upload and import dialog - [template] update bookmark import options - allow adding tags to all imported links - allow selecting the visibility (privacy) of imported links - [tests] ensure bookmarks are properly parsed and imported in the LinkDB - reuse reference input from the parser's test data See: - https://github.com/shaarli/netscape-bookmark-parser - https://getcomposer.org/doc/01-basic-usage.md#autoloading Signed-off-by: VirtualTam <[email protected]>
efed72f
to
a973afe
Compare
|
w00t! thanks @ArthurHoaro for the merge :) |
No problem, thanks for your work on this! =) |
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Additions: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile TODO: - [prod][php] use Composer to resolve PHP dependencies - [prod] refactor Dockerfile Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile - [prod][master][php] use Composer to resolve PHP dependencies - [prod][master] refactor Dockerfile TODO: - [prod][stable][php] use Composer to resolve PHP dependencies - [prod][stable] refactor Dockerfile Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile - [prod][master][php] use Composer to resolve PHP dependencies - [prod][master] refactor Dockerfile Commented modifications: - [prod][stable][php] use Composer to resolve PHP dependencies - [prod][stable] refactor Dockerfile Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile - [prod][master][php] use Composer to resolve PHP dependencies - [prod][master] refactor Dockerfile - [prod][stable] refactor Dockerfile Commented modifications: - [prod][stable][php] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Thank you all |
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile - [prod][master] refactor Dockerfile - [prod][master][php] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 Relates to shaarli#633 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [prod][stable] refactor Dockerfile - [prod][stable] set $TERM=dumb to avoid debconf-related issues - [prod][stable] install ca-certificates - [prod][stable] cleanup APT cache after installing packages - [prod][stable] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Relates to #607 Relates to #612 Relates to shaarli/netscape-bookmark-parser#15 Modification: - reference the "shaarli" vendor repository on Packagist instead of overriding the upstream package with an SCM repository See https://packagist.org/packages/shaarli/netscape-bookmark-parser Signed-off-by: VirtualTam <[email protected]>
Relates to #607 Relates to #612 Relates to #624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile - [prod][master] refactor Dockerfile - [prod][master][php] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Relates to #607 Relates to #612 Relates to #624 Relates to #633 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [prod][stable] refactor Dockerfile - [prod][stable] set $TERM=dumb to avoid debconf-related issues - [prod][stable] install ca-certificates - [prod][stable] cleanup APT cache after installing packages - [prod][stable] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli/netscape-bookmark-parser#15 Modification: - reference the "shaarli" vendor repository on Packagist instead of overriding the upstream package with an SCM repository See https://packagist.org/packages/shaarli/netscape-bookmark-parser Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [all][env] set $TERM=dumb to avoid debconf-related issues - [all][pkg] install ca-certificates - [all][pkg] cleanup APT cache after installing packages - [dev] refactor Dockerfile - [prod][master] refactor Dockerfile - [prod][master][php] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Relates to shaarli#607 Relates to shaarli#612 Relates to shaarli#624 Relates to shaarli#633 See https://github.com/shaarli/Shaarli/wiki/Server-requirements Modifications: - [prod][stable] refactor Dockerfile - [prod][stable] set $TERM=dumb to avoid debconf-related issues - [prod][stable] install ca-certificates - [prod][stable] cleanup APT cache after installing packages - [prod][stable] use Composer to resolve PHP dependencies Signed-off-by: VirtualTam <[email protected]>
Relates to #607
Relates to #608
Relates to #493 (abandoned)
Additions:
Modifications:
See: