Fix Outlook calendar fetching issues in Obsidian 1.9.0

- Fix calendar fetching broken by Chromium 138 header validation
- Improve Outlook calendar compatibility with simplified headers
- Add robust HTML error page detection and multiple retry strategies
- Enhance error handling with user-friendly notifications
- Add calendar data validation to ensure valid iCalendar format
- Update to version 1.6.3

Resolves issues where Outlook calendars returned HTML error pages
instead of calendar data when using complex browser headers.
This commit is contained in:
Michalis Efstratiadis 2025-08-21 07:26:53 +03:00
parent a6a1b5094c
commit 94a58d3118
No known key found for this signature in database
4 changed files with 17 additions and 19 deletions

View file

@ -1,7 +1,7 @@
{
"id": "memochron",
"name": "MemoChron",
"version": "1.6.2",
"version": "1.6.3",
"minAppVersion": "1.8.9",
"description": "Calendar integration and note creation with support for public iCalendar URLs",
"author": "Michalis Efstratiadis",

View file

@ -1,6 +1,6 @@
{
"name": "memochron",
"version": "1.6.0",
"version": "1.6.3",
"description": "Calendar integration and note creation plugin for Obsidian",
"main": "main.js",
"scripts": {

View file

@ -321,8 +321,6 @@ export class CalendarService {
private async fetchRemoteCalendar(url: string) {
// Special handling for Outlook/Office365 URLs
if (url.includes('outlook.office365.com') || url.includes('outlook.live.com')) {
console.log(`Fetching Outlook calendar from: ${url}`);
// First attempt: Try with simple browser-like headers
let response = await requestUrl({
url,
@ -334,33 +332,31 @@ export class CalendarService {
throw: false,
});
console.log(`Outlook response status: ${response.status}`);
console.log(`Response content type: ${response.headers?.['content-type'] || 'unknown'}`);
console.log(`Response text preview: ${response.text?.substring(0, 200)}`);
// Check if we got valid calendar data on first try
if (response.text && response.text.includes('BEGIN:VCALENDAR')) {
return response;
}
// Check if we got an HTML error page instead of calendar data
if (response.text && response.text.includes('<!DOCTYPE html>')) {
console.error(`Outlook calendar returned HTML error page for ${url}`);
console.error(`Full HTML response: ${response.text.substring(0, 500)}`);
// More robust check: HTML response typically has content-type text/html
const isHtmlResponse = (response.headers?.['content-type']?.includes('text/html')) ||
(response.text && (response.text.includes('<!DOCTYPE html') || response.text.includes('<html')));
if (isHtmlResponse) {
console.error(`Outlook calendar returned HTML error page for ${url.substring(0, 50)}...`);
// Try with no headers at all (let Obsidian use defaults)
console.log("Retrying with no custom headers...");
response = await requestUrl({
url,
method: "GET",
throw: false,
});
console.log(`Retry response status: ${response.status}`);
console.log(`Retry response preview: ${response.text?.substring(0, 200)}`);
if (response.text && response.text.includes('BEGIN:VCALENDAR')) {
console.log("Success with no headers!");
return response;
}
// Last attempt: Try with text/calendar accept header
console.log("Final attempt with text/calendar accept header...");
response = await requestUrl({
url,
method: "GET",
@ -371,14 +367,15 @@ export class CalendarService {
});
if (response.text && response.text.includes('BEGIN:VCALENDAR')) {
console.log("Success with text/calendar header!");
return response;
}
new Notice("MemoChron: Outlook calendar access failed. The URL works in browser but not in Obsidian. This may be due to Obsidian's network restrictions.");
// Return proper response structure
return {
...response,
status: 403,
text: "Outlook calendar blocked - please check console for details"
text: ""
};
}

View file

@ -24,5 +24,6 @@
"1.5.2": "1.8.9",
"1.5.3": "1.8.9",
"1.6.0": "1.8.9",
"1.6.2": "1.8.9"
"1.6.2": "1.8.9",
"1.6.3": "1.8.9"
}