From f45496336f5bbd31b69553fcfae9cdfd03b280cc Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Tue, 23 Apr 2019 22:28:36 +0200 Subject: Add ability to match many domains for credentials MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of fetching one domain, we use the same method as in site config (to retrieve the matching file) and handle api.example.org, example.org, .org (yes the last one isn’t useful). If one of these match, we got it and use it. --- .../GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php | 12 +++++++++++- .../CoreBundle/Repository/SiteCredentialRepository.php | 8 ++++---- .../CoreBundle/Resources/translations/messages.da.yml | 2 +- .../CoreBundle/Resources/translations/messages.de.yml | 2 +- .../CoreBundle/Resources/translations/messages.en.yml | 2 +- .../CoreBundle/Resources/translations/messages.es.yml | 2 +- .../CoreBundle/Resources/translations/messages.fa.yml | 2 +- .../CoreBundle/Resources/translations/messages.fr.yml | 2 +- .../CoreBundle/Resources/translations/messages.it.yml | 2 +- .../CoreBundle/Resources/translations/messages.oc.yml | 2 +- .../CoreBundle/Resources/translations/messages.pl.yml | 2 +- .../CoreBundle/Resources/translations/messages.pt.yml | 2 +- .../CoreBundle/Resources/translations/messages.ro.yml | 2 +- .../CoreBundle/Resources/translations/messages.th.yml | 2 +- 14 files changed, 27 insertions(+), 17 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php index 90e00c62..718441bd 100644 --- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php +++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php @@ -64,7 +64,17 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder $credentials = null; if ($this->currentUser) { - $credentials = $this->credentialRepository->findOneByHostAndUser($host, $this->currentUser->getId()); + $hosts = [$host]; + // will try to see for a host without the first subdomain (fr.example.org & .example.org) + $split = explode('.', $host); + + if (\count($split) > 1) { + // remove first subdomain + array_shift($split); + $hosts[] = '.' . implode('.', $split); + } + + $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId()); } if (null === $credentials) { diff --git a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php index b2e212a4..aeadd770 100644 --- a/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php +++ b/src/Wallabag/CoreBundle/Repository/SiteCredentialRepository.php @@ -19,16 +19,16 @@ class SiteCredentialRepository extends \Doctrine\ORM\EntityRepository /** * Retrieve one username/password for the given host and userId. * - * @param string $host - * @param int $userId + * @param array $hosts An array of host to look for + * @param int $userId * * @return array|null */ - public function findOneByHostAndUser($host, $userId) + public function findOneByHostsAndUser($hosts, $userId) { $res = $this->createQueryBuilder('s') ->select('s.username', 's.password') - ->where('s.host = :hostname')->setParameter('hostname', $host) + ->where('s.host IN (:hosts)')->setParameter('hosts', $hosts) ->andWhere('s.user = :userId')->setParameter('userId', $userId) ->setMaxResults(1) ->getQuery() diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 97eb874d..6f842534 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -550,7 +550,7 @@ site_credential: # create_new_one: Create a new credential # form: # username_label: 'Username' - # host_label: 'Host' + # host_label: 'Host (subdomain.example.org, .example.org, etc.)' # password_label: 'Password' # save: Save # delete: Delete diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 0cf3b138..874908b9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -550,7 +550,7 @@ site_credential: create_new_one: 'Einen neuen Seitenzugang anlegen' form: username_label: 'Benutzername' - host_label: 'Host' + host_label: 'Host (subdomain.example.org, .example.org, etc.)' password_label: 'Passwort' save: 'Speichern' delete: 'Löschen' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 6085be14..598ad58d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -550,7 +550,7 @@ site_credential: create_new_one: Create a new credential form: username_label: 'Username' - host_label: 'Host' + host_label: 'Host (subdomain.example.org, .example.org, etc.)' password_label: 'Password' save: Save delete: Delete diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index f2a8fb89..f8aa4109 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -550,7 +550,7 @@ site_credential: # create_new_one: Create a new credential # form: # username_label: 'Username' - # host_label: 'Host' + # host_label: 'Host (subdomain.example.org, .example.org, etc.)' # password_label: 'Password' # save: Save # delete: Delete diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index a5cbd7ec..785e39ee 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -550,7 +550,7 @@ site_credential: # create_new_one: Create a new credential # form: # username_label: 'Username' - # host_label: 'Host' + # host_label: 'Host (subdomain.example.org, .example.org, etc.)' # password_label: 'Password' # save: Save # delete: Delete diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index a36d84ae..b2fa1c50 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -550,7 +550,7 @@ site_credential: create_new_one: Créer un nouvel accès à un site form: username_label: 'Identifiant' - host_label: 'Domaine' + host_label: 'Domaine (subdomain.example.org, .example.org, etc.)' password_label: 'Mot de passe' save: "Sauvegarder" delete: "Supprimer" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 1649c0e4..ecaa3b60 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -550,7 +550,7 @@ site_credential: # create_new_one: Create a new credential # form: # username_label: 'Username' - # host_label: 'Host' + # host_label: 'Host (subdomain.example.org, .example.org, etc.)' # password_label: 'Password' # save: Save # delete: Delete diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index e2298f1f..848c88d2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -550,7 +550,7 @@ site_credential: create_new_one: Crear un novèl identificant form: username_label: "Nom d'utilizaire" - host_label: 'Òste' + host_label: 'Òste (subdomain.example.org, .example.org, etc.)' password_label: 'Senhal' save: 'Enregistrar' delete: 'Suprimir' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index a5712733..a0032fe8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -550,7 +550,7 @@ site_credential: create_new_one: Stwórz nowe poświadczenie form: username_label: 'Nazwa użytkownika' - host_label: 'Host' + host_label: 'Host (subdomain.example.org, .example.org, etc.)' password_label: 'Hasło' save: Zapisz delete: Usuń diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 1ccf49e1..292fad61 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -550,7 +550,7 @@ site_credential: # create_new_one: Create a new credential form: # username_label: 'Username' - # host_label: 'Host' + # host_label: 'Host (subdomain.example.org, .example.org, etc.)' # password_label: 'Password' save: 'Salvar' delete: 'Apagar' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 6c0e18e1..9e8d68b3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -550,7 +550,7 @@ site_credential: # create_new_one: Create a new credential # form: # username_label: 'Username' - # host_label: 'Host' + # host_label: 'Host (subdomain.example.org, .example.org, etc.)' # password_label: 'Password' # save: Save # delete: Delete diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml index 5524b1f1..cb3b0f23 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml @@ -548,7 +548,7 @@ site_credential: create_new_one: สร้างข้อมูลส่วนตัวใหม่ form: username_label: 'ชื่อผู้ใช้' - host_label: 'โฮส' + host_label: 'โฮส (subdomain.example.org, .example.org, etc.)' password_label: 'รหัสผ่าน' save: บันทึก delete: ลบ -- cgit v1.2.3 From 35359bd3c67e5b6c6371e2e547a3411ca0a8027b Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Wed, 24 Apr 2019 15:28:15 +0200 Subject: Adding more tests to cover different scenario --- .../DataFixtures/ORM/LoadSiteCredentialData.php | 27 ++++++++++++++++++---- .../GrabySiteConfigBuilder.php | 27 ++++++++++++---------- 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php index 866f55a4..faf29da6 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSiteCredentialData.php @@ -5,19 +5,38 @@ namespace Wallabag\CoreBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\Persistence\ObjectManager; +use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; use Wallabag\CoreBundle\Entity\SiteCredential; -class LoadSiteCredentialData extends AbstractFixture implements OrderedFixtureInterface +class LoadSiteCredentialData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface { + /** + * @var ContainerInterface + */ + private $container; + + public function setContainer(ContainerInterface $container = null) + { + $this->container = $container; + } + /** * {@inheritdoc} */ public function load(ObjectManager $manager) { $credential = new SiteCredential($this->getReference('admin-user')); - $credential->setHost('example.com'); - $credential->setUsername('foo'); - $credential->setPassword('bar'); + $credential->setHost('.super.com'); + $credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('.super')); + $credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); + + $manager->persist($credential); + + $credential = new SiteCredential($this->getReference('admin-user')); + $credential->setHost('paywall.example.com'); + $credential->setUsername($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('paywall.example')); + $credential->setPassword($this->container->get('wallabag_core.helper.crypto_proxy')->crypt('bar')); $manager->persist($credential); diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php index 718441bd..c7502bac 100644 --- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php +++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php @@ -62,21 +62,24 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder $host = substr($host, 4); } - $credentials = null; - if ($this->currentUser) { - $hosts = [$host]; - // will try to see for a host without the first subdomain (fr.example.org & .example.org) - $split = explode('.', $host); - - if (\count($split) > 1) { - // remove first subdomain - array_shift($split); - $hosts[] = '.' . implode('.', $split); - } + if (!$this->currentUser) { + $this->logger->debug('Auth: no current user defined.'); + + return false; + } + + $hosts = [$host]; + // will try to see for a host without the first subdomain (fr.example.org & .example.org) + $split = explode('.', $host); - $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId()); + if (\count($split) > 1) { + // remove first subdomain + array_shift($split); + $hosts[] = '.' . implode('.', $split); } + $credentials = $this->credentialRepository->findOneByHostsAndUser($hosts, $this->currentUser->getId()); + if (null === $credentials) { $this->logger->debug('Auth: no credentials available for host.', ['host' => $host]); -- cgit v1.2.3 From 4b5b228650cd109db7b21fd754581416e7f7d97e Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Sat, 27 Apr 2019 22:48:28 +0200 Subject: material: add metadata to list view Add reading time and creation date to rows of list view. Refactor styles using a sass mixin. Fixes #3838 Signed-off-by: Kevin Decherf --- .../Resources/views/themes/material/Entry/Card/_content.html.twig | 5 ++++- .../Resources/views/themes/material/Entry/_card_list.html.twig | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig index 1f3cd1a7..1102a0bd 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_content.html.twig @@ -8,8 +8,11 @@
{{ entry.domainName|removeWww }} - {% if withTags is defined %} + {% if withMetadata is defined %} {% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags | slice(0, 3), 'entryId': entry.id, 'listClass': ' hide-on-med-and-down'} only %} +
+
{% include "@WallabagCore/themes/material/Entry/_reading_time.html.twig" with {'entry': entry} only %}
+
{% endif %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig index 1c00f2fa..6a095035 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig @@ -5,7 +5,7 @@ - {% include "@WallabagCore/themes/material/Entry/Card/_content.html.twig" with {'entry': entry, 'withTags': true, 'subClass': 'metadata'} only %} + {% include "@WallabagCore/themes/material/Entry/Card/_content.html.twig" with {'entry': entry, 'withMetadata': true, 'subClass': 'metadata'} only %}
  • {% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %} -- cgit v1.2.3 From 2dbb5b2307ceefc92b465a7cbd2d0ecf512a491b Mon Sep 17 00:00:00 2001 From: Kevin Decherf Date: Wed, 1 May 2019 14:05:38 +0200 Subject: Enable no-referrer on img tags, enable strict-origin-when-cross-origin by default Fixes #3889 Signed-off-by: Kevin Decherf --- src/Wallabag/CoreBundle/Helper/ContentProxy.php | 1 + src/Wallabag/CoreBundle/Resources/views/base.html.twig | 1 + 2 files changed, 2 insertions(+) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php index 31953f12..bc257ffb 100644 --- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php +++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php @@ -47,6 +47,7 @@ class ContentProxy */ public function updateEntry(Entry $entry, $url, array $content = [], $disableContentUpdate = false) { + $this->graby->toggleImgNoReferrer(true); if (!empty($content['html'])) { $content['html'] = $this->graby->cleanupHtml($content['html'], $url); } diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index aa388bcb..c0eecd57 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -8,6 +8,7 @@ {% block head %} + -- cgit v1.2.3 From 19822ecb31a6ca6224abbaf1c23b2a30b5b4496c Mon Sep 17 00:00:00 2001 From: Matt Burke Date: Wed, 17 Apr 2019 22:21:17 -0400 Subject: Remove preview picture from share view page for #1875 Essentially, same as commit 038fccd for single entry views. From that commit: > Showing the preview picture usually leads to showing a duplicate > image, and frequently leads to showing duplicate images directly > adjacent to each other. --- .../CoreBundle/Resources/views/themes/common/Entry/share.html.twig | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/share.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/share.html.twig index e1c7aad9..4294a60d 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/share.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Entry/share.html.twig @@ -29,9 +29,6 @@

    {{ entry.title|e|raw }}

    {{ entry.domainName|removeWww }}

    {{ "entry.public.shared_by_wallabag"|trans({'%wallabag_instance%': url('homepage'), '%username%': entry.user.username})|raw }}.

    - {% if entry.previewPicture is not null %} - {{ entry.title|striptags|e('html_attr') }} - {% endif %}
    {{ entry.content | raw }} -- cgit v1.2.3