You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import basicAuth from 'basic-auth-connect';
const cookieParser = require('cookie-parser');
const server = express();
server.use(cookieParser(process.env.COOKIE_SECRET));
server.disable('x-powered-by');
server.all(
'/*',
basicAuth(
(user: string, passwd: string) =>
user === 'username' && passwd === 'passwd ',
),
);
// Middleware to catch and validate URL encoding
server.use((req, res, next) => {
try {
decodeURIComponent(req.url); // Try to decode the URL
next(); // Continue if decoding is successful
} catch (err) {
// If decoding fails, return a 400 Bad Request with a custom error message
res.status(400).send({ error: 'Invalid URL encoding' });
}
});
server.use('*', express.static(__dirname + '/static/'));
export const newapp = functions.https.onRequest(
{},
server,
);
[REQUIRED] Steps to reproduce
Link to https cloud functions gen2 ( Cloud run ) : https://myapp-<hash>-an.a.run.app
Try access url https://myapp-<hash>-an.a.run.app/%C3 with param or query that contain encoded characters like Windows-1252 , ISO-8859-1( Example: %C3 ) will return internal server error.
[REQUIRED] Expected behavior
Function can access url contain other than UTF-8 encoded characters without throw internal server error. ( Or just throw 400 bad request )
[REQUIRED] Actual behavior
Error: No default engine was specified and no extension was provided.
Were you able to successfully deploy your functions?
Function is successfully deployed, only occur an error when meet special characters in url.
The text was updated successfully, but these errors were encountered:
Skyfury2651
changed the title
Firebase functions can't accept Windows-1252 URL encoding
Firebase functions can't accept any encoding other than UTF-8 for URLs.
Nov 22, 2024
Related issues
[REQUIRED] Version info
node:
v20.11.0
firebase-functions: v4.9.0
firebase-tools: 13.25.0
firebase-admin: ^12.0.0
[REQUIRED] Test case
[REQUIRED] Steps to reproduce
Link to https cloud functions gen2 ( Cloud run ) :
https://myapp-<hash>-an.a.run.app
Try access url
https://myapp-<hash>-an.a.run.app/%C3
with param or query that contain encoded characters like Windows-1252 , ISO-8859-1( Example: %C3 ) will return internal server error.[REQUIRED] Expected behavior
Function can access url contain other than UTF-8 encoded characters without throw internal server error. ( Or just throw 400 bad request )
[REQUIRED] Actual behavior
Error: No default engine was specified and no extension was provided.
Were you able to successfully deploy your functions?
Function is successfully deployed, only occur an error when meet special characters in url.
The text was updated successfully, but these errors were encountered: