Skip to content
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

Improved validation regular expressions to support specific attribute names #356

Merged
merged 17 commits into from
Jan 3, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dart_quotes/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.0
jaspr_web_compilers: ^4.0.10
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
lints: ^4.0.0

jaspr:
Expand Down
14 changes: 8 additions & 6 deletions apps/dart_quotes_server/client/lib/src/protocol/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ class EndpointQuotes extends _i1.EndpointRef {
);
}

class _Modules {
_Modules(Client client) {
class Modules {
Modules(Client client) {
auth = _i4.Caller(client);
}

Expand Down Expand Up @@ -75,19 +75,21 @@ class Client extends _i1.ServerpodClientShared {
connectionTimeout: connectionTimeout,
onFailedCall: onFailedCall,
onSucceededCall: onSucceededCall,
disconnectStreamsOnLostInternetConnection: disconnectStreamsOnLostInternetConnection,
disconnectStreamsOnLostInternetConnection:
disconnectStreamsOnLostInternetConnection,
) {
quotes = EndpointQuotes(this);
modules = _Modules(this);
modules = Modules(this);
}

late final EndpointQuotes quotes;

late final _Modules modules;
late final Modules modules;

@override
Map<String, _i1.EndpointRef> get endpointRefLookup => {'quotes': quotes};

@override
Map<String, _i1.ModuleEndpointCaller> get moduleLookup => {'auth': modules.auth};
Map<String, _i1.ModuleEndpointCaller> get moduleLookup =>
{'auth': modules.auth};
}
15 changes: 9 additions & 6 deletions apps/dart_quotes_server/client/lib/src/protocol/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters

library protocol; // ignore_for_file: no_leading_underscores_for_library_prefixes

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod_client/serverpod_client.dart' as _i1;
import 'quote.dart' as _i2;
import 'quote_init.dart' as _i3;
Expand Down Expand Up @@ -71,14 +70,18 @@ class Protocol extends _i1.SerializationManager {

@override
dynamic deserializeByClassName(Map<String, dynamic> data) {
if (data['className'] == 'Quote') {
var dataClassName = data['className'];
if (dataClassName is! String) {
return super.deserializeByClassName(data);
}
if (dataClassName == 'Quote') {
return deserialize<_i2.Quote>(data['data']);
}
if (data['className'] == 'QuoteInit') {
if (dataClassName == 'QuoteInit') {
return deserialize<_i3.QuoteInit>(data['data']);
}
if (data['className'].startsWith('serverpod_auth.')) {
data['className'] = data['className'].substring(15);
if (dataClassName.startsWith('serverpod_auth.')) {
data['className'] = dataClassName.substring(15);
return _i4.Protocol().deserializeByClassName(data);
}
return super.deserializeByClassName(data);
Expand Down
4 changes: 2 additions & 2 deletions apps/dart_quotes_server/client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ environment:
sdk: '>=3.1.0 <4.0.0'

dependencies:
serverpod_auth_client: 2.1.1
serverpod_client: 2.1.1
serverpod_auth_client: 2.3.0
serverpod_client: 2.3.0
4 changes: 2 additions & 2 deletions apps/dart_quotes_server/config/passwords.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ shared:

# These are passwords used when running the server locally in development mode
development:
database: 'CHANGE_ME'
redis: 'CHANGE_ME'
database: "CHANGE_ME"
redis: "CHANGE_ME"

# The service secret is used to communicate between servers and to access the
# service protocol.
Expand Down
22 changes: 13 additions & 9 deletions apps/dart_quotes_server/lib/src/generated/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
// ignore_for_file: type_literal_in_constant_pattern
// ignore_for_file: use_super_parameters

library protocol; // ignore_for_file: no_leading_underscores_for_library_prefixes

// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod/serverpod.dart' as _i1;
import 'package:serverpod/protocol.dart' as _i2;
import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3;
Expand Down Expand Up @@ -133,18 +132,22 @@ class Protocol extends _i1.SerializationManagerServer {

@override
dynamic deserializeByClassName(Map<String, dynamic> data) {
if (data['className'] == 'Quote') {
var dataClassName = data['className'];
if (dataClassName is! String) {
return super.deserializeByClassName(data);
}
if (dataClassName == 'Quote') {
return deserialize<_i4.Quote>(data['data']);
}
if (data['className'] == 'QuoteInit') {
if (dataClassName == 'QuoteInit') {
return deserialize<_i5.QuoteInit>(data['data']);
}
if (data['className'].startsWith('serverpod.')) {
data['className'] = data['className'].substring(10);
if (dataClassName.startsWith('serverpod.')) {
data['className'] = dataClassName.substring(10);
return _i2.Protocol().deserializeByClassName(data);
}
if (data['className'].startsWith('serverpod_auth.')) {
data['className'] = data['className'].substring(15);
if (dataClassName.startsWith('serverpod_auth.')) {
data['className'] = dataClassName.substring(15);
return _i3.Protocol().deserializeByClassName(data);
}
return super.deserializeByClassName(data);
Expand Down Expand Up @@ -172,7 +175,8 @@ class Protocol extends _i1.SerializationManagerServer {
}

@override
List<_i2.TableDefinition> getTargetTableDefinitions() => targetTableDefinitions;
List<_i2.TableDefinition> getTargetTableDefinitions() =>
targetTableDefinitions;

@override
String getModuleName() => 'dart_quotes';
Expand Down
9 changes: 6 additions & 3 deletions apps/dart_quotes_server/lib/src/generated/quote.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod/serverpod.dart' as _i1;

abstract class Quote extends _i1.TableRow implements _i1.ProtocolSerialization {
abstract class Quote implements _i1.TableRow, _i1.ProtocolSerialization {
Quote._({
int? id,
this.id,
required this.quote,
required this.author,
required this.likes,
}) : super(id);
});

factory Quote({
int? id,
Expand All @@ -39,6 +39,9 @@ abstract class Quote extends _i1.TableRow implements _i1.ProtocolSerialization {

static const db = QuoteRepository._();

@override
int? id;

String quote;

String author;
Expand Down
3 changes: 2 additions & 1 deletion apps/dart_quotes_server/lib/src/generated/quote_init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// ignore_for_file: no_leading_underscores_for_library_prefixes
import 'package:serverpod/serverpod.dart' as _i1;

abstract class QuoteInit implements _i1.SerializableModel, _i1.ProtocolSerialization {
abstract class QuoteInit
implements _i1.SerializableModel, _i1.ProtocolSerialization {
QuoteInit._({required this.id});

factory QuoteInit({required int id}) = _QuoteInitImpl;
Expand Down
14 changes: 7 additions & 7 deletions apps/dart_quotes_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ dependencies:
path: ./client
jaspr: ^0.16.0
jaspr_router: ^0.6.0
jaspr_serverpod: ^0.4.0
serverpod: 2.1.1
serverpod_auth_google_flutter: 2.1.1
serverpod_auth_server: 2.1.1
serverpod_auth_shared_flutter: 2.1.1
serverpod_serialization: 2.1.1
jaspr_serverpod: ^0.5.0
serverpod: 2.3.0
serverpod_auth_google_flutter: 2.3.0
serverpod_auth_server: 2.3.0
serverpod_auth_shared_flutter: 2.3.0
serverpod_serialization: 2.3.0

dev_dependencies:
build_runner: ^2.4.0
jaspr_web_compilers: ^4.0.10
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
lints: ^4.0.0

jaspr:
Expand Down
2 changes: 1 addition & 1 deletion apps/fluttercon/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dev_dependencies:
build_runner: ^2.4.0
dart_mappable_builder: ^4.2.3
jaspr_web_compilers: ^4.0.10
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
lints: ^4.0.0

jaspr:
Expand Down
2 changes: 1 addition & 1 deletion apps/jaspr_pad/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.0
dart_mappable_builder: ^4.2.0
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
jaspr_test: ^0.15.1
lints: ^4.0.0
test: ^1.25.0
Expand Down
4 changes: 2 additions & 2 deletions examples/backend_dart_frog/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.0
jaspr_builder: ^0.15.0
jaspr_builder: ^0.16.3
lints: ^2.1.0

dependency_overrides:
hotreloader: ^4.1.0

jaspr:
mode: server
dev-command: dart_frog dev
2 changes: 1 addition & 1 deletion examples/backend_serverpod/example_client/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ environment:
sdk: '>=3.0.0 <4.0.0'

dependencies:
serverpod_client: 2.1.1
serverpod_client: 2.3.0
4 changes: 2 additions & 2 deletions examples/backend_serverpod/example_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ environment:

dependencies:
jaspr: ^0.15.0
jaspr_serverpod: ^0.3.3
serverpod: 2.1.1
jaspr_serverpod: ^0.5.0
serverpod: 2.3.0

dev_dependencies:
build_runner: ^2.4.8
Expand Down
2 changes: 1 addition & 1 deletion examples/backend_shelf/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.0
jaspr_builder: ^0.15.0
jaspr_builder: ^0.16.3
lints: ^2.1.0

jaspr:
Expand Down
2 changes: 1 addition & 1 deletion examples/flutter_embedding/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^4.0.0
jaspr_builder: ^0.16.1
jaspr_builder: ^0.16.3
jaspr_web_compilers: ^4.0.10

flutter:
Expand Down
6 changes: 3 additions & 3 deletions examples/flutter_multi_view/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ environment:

dependencies:
flutter:
sdk: flutter
sdk: flutter
jaspr: ^0.16.0
jaspr_flutter_embed: ^0.4.0

dev_dependencies:
build_runner: ^2.4.0
jaspr_web_compilers: ^4.0.10
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
jaspr_lints: ^0.1.1
jaspr_lints: ^0.1.2

jaspr:
mode: static
Expand Down
2 changes: 1 addition & 1 deletion examples/flutter_plugin_interop/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies:

dev_dependencies:
build_runner: ^2.4.0
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
jaspr_web_compilers: ^4.0.10
lints: ^4.0.0

Expand Down
2 changes: 1 addition & 1 deletion examples/package_riverpod/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.0
build_web_compilers: ^4.0.0
jaspr_builder: ^0.15.1
jaspr_builder: ^0.16.3
lints: ^4.0.0

jaspr:
Expand Down
3 changes: 3 additions & 0 deletions packages/jaspr/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Unreleased 0.16.4
gonft marked this conversation as resolved.
Show resolved Hide resolved
- Fixed improved validation regular expressions to support specific attribute names

## 0.16.3

- Added `table` and related html methods.
Expand Down
2 changes: 1 addition & 1 deletion packages/jaspr/lib/src/server/markup_render_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class MarkupRenderObject extends RenderObject {

/// DOM validator with sane defaults.
class DomValidator {
static final _attributeRegExp = RegExp(r'^[a-z](?:[a-zA-Z0-9\-_:.]*[a-z0-9]+)?$');
static final _attributeRegExp = RegExp(r'^[@a-z:](?:[a-zA-Z0-9\-_:.]*[a-z0-9]+)?$');
static final _elementRegExp = _attributeRegExp;
static const _selfClosing = <String>{
'area',
Expand Down
Loading
Loading