* [PATCH fb v1 0/3] A small bug fix for the mbasic changes
@ 2023-06-28 19:58 Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 1/3] fb: Fix `getCache()` expiration logic handling Ammar Faizi
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Ammar Faizi @ 2023-06-28 19:58 UTC (permalink / raw)
To: GNU/Weeb Mailing List
Cc: Ammar Faizi, Michael William Jonathan, Nicholas Rosenberg,
GNU/Weeb Facebook Team, VNLX Kernel Department
Hi,
Michael reports that using the recent API, photo contents in the
HonkaiStarRail.ID timeline are detected as a "text".
Using the current parser, it detects those contents as a text with a
link preview (where the preview is the post to the photo). Let's just
visit the photo link if there exists before continue trying to parse
it as a photo. Also, make sure we try to parse as a photo first before
text.
There are 3 patches in this series. The first and the second patches
are just a simple tweak and clean up. The third patch is the fix to
the serious issue.
Patch 1:
The getCache() function doesn't take the expiration date into account.
Make sure it does.
Patch 2:
I often generate patch files in the same directory with the project
directory. I don't want to commit them. Add '*.patch' to .gitignore to
avoid that.
Patch 3:
The fix that's explained in the introduction.
Signed-off-by: Ammar Faizi <[email protected]>
---
The following changes since commit dbc3dfcc32af4b934c0ace3dd7efbfe9878f133f:
Merge branch 'dev.fast_asset' (Facebook Onion assets optimization) (2023-05-13 02:01:05 +0700)
are available in the Git repository at:
https://gitlab.torproject.org/ammarfaizi2/Facebook.git dev
for you to fetch changes up to 0a1c38b9315cad0c6149c17beffae514d0ab93d5:
fb: Post: Fix the wrong content type detection (photo issue) (2023-06-25 13:58:47 +0700)
----------------------------------------------------------------
Ammar Faizi (3):
fb: Fix `getCache()` expiration logic handling
fb: .gitignore: Ignore *.patch files
fb: Post: Fix the wrong content type detection (photo issue)
.gitignore | 3 ++-
src/Facebook/Facebook.php | 5 +++++
src/Facebook/Methods/Post.php | 9 +++++++--
3 files changed, 14 insertions(+), 3 deletions(-)
base-commit: dbc3dfcc32af4b934c0ace3dd7efbfe9878f133f
--
Ammar Faizi
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH fb v1 1/3] fb: Fix `getCache()` expiration logic handling
2023-06-28 19:58 [PATCH fb v1 0/3] A small bug fix for the mbasic changes Ammar Faizi
@ 2023-06-28 19:58 ` Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 2/3] fb: .gitignore: Ignore *.patch files Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 3/3] fb: Post: Fix the wrong content type detection (photo issue) Ammar Faizi
2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2023-06-28 19:58 UTC (permalink / raw)
To: GNU/Weeb Mailing List
Cc: Ammar Faizi, Michael William Jonathan, Nicholas Rosenberg,
GNU/Weeb Facebook Team, VNLX Kernel Department
The getCache() function doesn't take the expiration date into account.
Make sure it does.
Fixes: 88952f396b1b4831eab3b8ed5d71959e42686a88 ("fb: Introduce `getCache()` and `setCache()` functions")
Signed-off-by: Ammar Faizi <[email protected]>
---
src/Facebook/Facebook.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/Facebook/Facebook.php b/src/Facebook/Facebook.php
index 00aed812693248a8..6afd735ca4aa6bca 100644
--- a/src/Facebook/Facebook.php
+++ b/src/Facebook/Facebook.php
@@ -306,6 +306,11 @@ class Facebook
return NULL;
}
+ if ($data["exp"] < time()) {
+ unlink($file);
+ return NULL;
+ }
+
return $data["data"];
}
--
Ammar Faizi
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH fb v1 2/3] fb: .gitignore: Ignore *.patch files
2023-06-28 19:58 [PATCH fb v1 0/3] A small bug fix for the mbasic changes Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 1/3] fb: Fix `getCache()` expiration logic handling Ammar Faizi
@ 2023-06-28 19:58 ` Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 3/3] fb: Post: Fix the wrong content type detection (photo issue) Ammar Faizi
2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2023-06-28 19:58 UTC (permalink / raw)
To: GNU/Weeb Mailing List
Cc: Ammar Faizi, Michael William Jonathan, Nicholas Rosenberg,
GNU/Weeb Facebook Team, VNLX Kernel Department
I often generate patch files in the same directory with the project
directory. I don't want to commit them. Add '*.patch' to .gitignore to
avoid that.
Signed-off-by: Ammar Faizi <[email protected]>
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index da9f1ac047357f8a..5c7d1aaaf7db1515 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,5 @@
*.tmp
*.log
-/tmp.html
\ No newline at end of file
+*.patch
+/tmp.html
--
Ammar Faizi
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH fb v1 3/3] fb: Post: Fix the wrong content type detection (photo issue)
2023-06-28 19:58 [PATCH fb v1 0/3] A small bug fix for the mbasic changes Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 1/3] fb: Fix `getCache()` expiration logic handling Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 2/3] fb: .gitignore: Ignore *.patch files Ammar Faizi
@ 2023-06-28 19:58 ` Ammar Faizi
2 siblings, 0 replies; 4+ messages in thread
From: Ammar Faizi @ 2023-06-28 19:58 UTC (permalink / raw)
To: GNU/Weeb Mailing List
Cc: Ammar Faizi, Michael William Jonathan, Nicholas Rosenberg,
GNU/Weeb Facebook Team, VNLX Kernel Department
Michael reports that using the recent API, photo contents in the
HonkaiStarRail.ID timeline are detected as a "text".
Using the current parser, it detects those contents as a text with a
link preview (where the preview is the post to the photo). Just visit
the photo link if there exists before continue trying to parse it as a
photo. Also, make sure we try to parse as a photo first before text.
Cc: Michael William Jonathan <[email protected]>
Signed-off-by: Ammar Faizi <[email protected]>
---
src/Facebook/Methods/Post.php | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/Facebook/Methods/Post.php b/src/Facebook/Methods/Post.php
index 7fe38c5c1b982c72..8c02d0f70e553c14 100644
--- a/src/Facebook/Methods/Post.php
+++ b/src/Facebook/Methods/Post.php
@@ -281,6 +281,11 @@ trait Post
"alt" => NULL,
];
+
+ if (preg_match("/\/photo.php\?fbid=(\d+)/", $o, $m)) {
+ $o = $this->http("/photo.php?fbid={$m[1]}", "GET")["out"];
+ }
+
/*
* Parse photo URLs. Currently, only one photo is parsed.
*/
@@ -341,12 +346,12 @@ trait Post
*/
private function parsePostContent(string $o): array
{
- $ret = $this->tryParseTextPost($o);
+ $ret = $this->tryParsePhotoPost($o);
if ($ret) {
return $ret;
}
- $ret = $this->tryParsePhotoPost($o);
+ $ret = $this->tryParseTextPost($o);
if ($ret) {
return $ret;
}
--
Ammar Faizi
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-28 19:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28 19:58 [PATCH fb v1 0/3] A small bug fix for the mbasic changes Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 1/3] fb: Fix `getCache()` expiration logic handling Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 2/3] fb: .gitignore: Ignore *.patch files Ammar Faizi
2023-06-28 19:58 ` [PATCH fb v1 3/3] fb: Post: Fix the wrong content type detection (photo issue) Ammar Faizi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox